TASK:
Finish writing the isEveryoneHere()
function so that it returns true
if the object passed to it contains all four names, Alan
, Jeff
, Sarah
and Ryan
and returns false
otherwise.
let users = {
Alan: {
age: 27,
online: true
},
Jeff: {
age: 32,
online: true
},
Sarah: {
age: 48,
online: true
},
Ryan: {
age: 19,
online: true
}
};
function isEveryoneHere(userObj) {
// Only change code below this line
switch(userObj){
case 'Alan'in userObj:
return true;
break;
case 'Jeff'in userObj:
return true;
break;
case 'Sarah'in userObj:
return true;
break;
case 'Ryan'in userObj:
return true;
break;
default:
return false;
}
}
// Final Solution:
/*
function isEveryoneHere(userObj) {
// Only change code below this line
if('Alan' in userObj && 'Jeff' in userObj&&
'Sarah' in userObj && 'Ryan' in userObj){
return true;
}
return false;
}*/
console.log(isEveryoneHere(users));