While compiling this code I am getting an error that obj is not iterable. Why? I have to check how many users are online
let users = {
Alan: {
age: 27,
online: false
},
Jeff: {
age: 32,
online: true
},
Sarah: {
age: 48,
online: false
},
Ryan: {
age: 19,
online: true
}
};
function countOnline(obj) {
let num =0;
for(let user of obj){
if(user['online']==true){
num++;
}
}
return num;
}
console.log(countOnline(users));