Tell us what’s happening:
so my if statement is suppose to return true if the property exist in object and false if it does not exist
my second if statement is not working please tell me whats going on.
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
let counter = 0;
for (let user in obj) {
if(obj[user].online === true){
counter ++;
return true
if (!obj[user].online) {
return false
}
}
}
return counter;
// change code above this line
}
console.log(isEveryoneHere(users));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property