The code below doesn’t work, but I can’t see why. The code in the hint/solution is a bit odd as it doesn’t actually use the function parameter (obj), also, it gives multiple parameters to hasOwnProperty, but this only takes one parameter so will only test the first parameter as far as I can see.
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
for (let i = 0; i < obj.length; i++) {
if (users.hasOwnProperty(obj[i]) === false) {
return false;
}
}
return true;
// change code above this line
}
console.log(isEveryoneHere(users));
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property/