function isEveryoneHere(userObj) {
// Only change code below this line
let objNames = Object.keys(userObj);
console.log(objNames)
let searchNames = ['Alan','Jeff','Sarah','Ryan']
if (objNames === searchNames) {
return true;
}
return false;
// Only change code above this line
}
function isEveryoneHere(userObj) {
// Only change code below this line
let objNames = Object.keys(userObj);
console.log(objNames)
let searchNames = ['Alan','Jeff','Sarah','Ryan']
console.log(searchNames)
console.log(typeof objNames)
console.log(typeof searchNames)
if (objNames.toString() == searchNames) {
return true;
}
return false;
// Only change code above this line
}
Try putting it in your code. You are comparing two objects. The result will always be false.
The only reason the code I showed you outputs true is that I used loose equality and not strict equality. What this means is that because I transformed the first element to a string the compiler automatically tries to convert the other element to a string. This approach is not recommended as errors can easily slip in. If you change the ‘==’ with ‘===’ you’ll see that it correctly outputs false.