Tell us what’s happening:
Hi,
I have noticed this second solution for the test :
function isEveryoneHere(obj) {
return [“Alan”, “Jeff”, “Sarah”, “Ryan”].every(name =>
obj.hasOwnProperty(name)
);
}
But I can’t read the method (function?) properly.Where we can find in our FreeCodeCamp lesson something about this notation? And how can I understand when to use it instead of a more classic one? I can see it may be an arrow function though…
Plus, do you know why the method do not evaluate an expression like this one and does not work: obj.hasOwnProperty(‘Alan’&&‘Jeff’&&‘Sarah’&&‘Ryan’);
Your code so far
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) {
// Only change code below this line
return obj.hasOwnProperty("Alan") &&
obj.hasOwnProperty("Jeff") &&
obj.hasOwnProperty("Sarah") &&
obj.hasOwnProperty("Ryan")
// Only change code above this line
}
console.log(isEveryoneHere(users));
/*function isEveryoneHere(obj) {
return ["Alan", "Jeff", "Sarah", "Ryan"].every(name =>
obj.hasOwnProperty(name)
);
}
*/
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36
.
Challenge: Check if an Object has a Property
Link to the challenge: