We have blurred this solution (with [spoiler][/spoiler] tags) so that users who have not completed this challenge can read the discussion in this thread without giving away the solution.
here’s my solution to this. Not the most elegant but it works
function isEveryoneHere(userObj) {
// Only change code below this line
let user = ['Alan', 'Jeff', 'Sarah', 'Ryan']
let check = 0;
for (let i = 0; i < user.length; i++)
if(user[i] in userObj == false) {
check = 1;
}
return check <= 0
}
I used a for loop as well. Not the best solution but it works fine.
function isEveryoneHere(userObj) {
let names = ['Alan', 'Jeff', 'Sarah', 'Ryan'];
let result = '';
for (let i = 0; i < names.length; i++) {
if (userObj.hasOwnProperty(names[i])) {
result = true;
} else {
result = false;
return result;
}
}
return result;
}