Tell us what’s happening:
Before attempting this challenge I checked on google if hasOwnProperty accepts more than one property at once and apparently it doesnt, it will only consider the first property entered, so I solved the problem as listed below. However afterwards I checked the solutions listed for this lesson and it is checking for multiple properties at once with hasOwnProperty. Am I missing smth or is the solution provided wrong?
function isEveryoneHere(obj) {
return (users.hasOwnProperty('Alan','Jeff','Sarah','Ryan')) ? true : false;
}
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) {
// change code below this line
return obj.hasOwnProperty('Alan') && obj.hasOwnProperty('Jeff') && obj.hasOwnProperty('Sarah') && obj.hasOwnProperty('Ryan') ? true : false;
// change code above this line
}
console.log(isEveryoneHere(users));
Your browser information:
User Agent is: Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property