// Iterate Through the Keys of an Objectconst usersObj ={Alan:{online:false,},Jeff:{online:true,},Sarah:{online:false,},};functioncountOnline(usersObj){let count =0;for(let user in usersObj){if(usersObj[user].online===true) count++;}return count;}console.log(countOnline(usersObj));
Iterate Through the Keys of an Object with a for...in Statement
let users ={Alan:{age:27,online:true},Jeff:{age:32,online:true},Sarah:{age:48,online:true},Ryan:{age:19,online:true}};functionisEveryoneHere(userObj){return["Alan","Jeff","Sarah","Ryan"].every(name=>
userObj.hasOwnProperty(name));}