js get object by id from array
myArray.find(x => x.id === '45');
js get object by id from array
myArray.find(x => x.id === '45');
Find items from object
// We've created an object, users, with some users in it and a function
// isEveryoneHere, which we pass the users object to as an argument.
// Finish writing this function so that it returns true only if the
// users object contains all four names, Alan, Jeff, Sarah, and Ryan, as keys, and false otherwise.
let users = {
Alan: {
age: 27,
online: true,
},
Jeff: {
age: 32,
online: true,
},
Sarah: {
age: 48,
online: true,
},
Ryan: {
age: 19,
online: true,
},
};
function isEveryoneHere(obj) {
return ['Alan', 'Jeff', 'Sarah', 'Ryan'].every((name) =>
obj.hasOwnProperty(name)
);
}
console.log(isEveryoneHere(users));
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us