Here is my code I'm trying to count how many online users we have with the countOnline function.
I'm getting the error "Cannot read property 'online' of undefined";
function countOnline(usersObj) {
let amount=0;
for(let user in usersObj){
if(usersObj.user.online){
amount++;
}
}
return amount;
}
let a = countOnline({
Alan: { online: false },
Jeff: { online: true },
Sarah: { online: false }
});
console.log(a);