I need to count the number of online user in this nested object, and return the total.
I've tried this code but I am kind of lost
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 c = 0;
for (let i in obj) {
for (let j in i) {
if (j.online === true) {
c++;
}
}
}
return c;
}
it returns 0