Hello,
link: https://beta.freecodecamp.org/en/challenges/basic-data-structures/check-if-an-object-has-a-property
Ok so i’m having a bug. Code not working:
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) {
for( let name in obj ) {
if( obj[name].online == false ) {
return false;
}
}
return true;
};
console.log(isEveryoneHere(users));
The users object only contains the keys Alan, Jeff, Sarah, and Ryan OK
The function isEveryoneHere returns true if Alan, Jeff, Sarah, and Ryan are properties on the users object OK
The function isEveryoneHere returns false if Alan, Jeff, Sarah, and Ryan are not properties on the users object NOT OK
And some thing is strange in the explanation. It say basicaly “every thing is true at the online key and if it’s not, return false”… But in the text at the end, it speak about “properties” and not the “value of the properties”.
So the property “online” have to exist AND have to be true everywhere at the same time to return true ?
If it is the case, it’s very badly explained.
thx yoo