I’ve solved this challenge already but I’d like to try using nested for loops. I cannot figure out why my code is not working. Console is saying “undefined”
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
obj = [];
let newObj = ['Alan', 'Jeff', 'Sarah', 'Ryan'];
for ( let j = 0; j < obj.length; j++ ) {
for ( let i = 0; i < newObj.length; i++ ) {
if ( obj[j] == newObj[i]) {
return true;
} return false;
}
}
// Only change code above this line
}
console.log(isEveryoneHere(users));
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36
.
Challenge: Check if an Object has a Property
Link to the challenge: