hey, i can’t figure it out, in theory what I thought I was typing would work but it’s not working like I want it to. It wont properly return the count of online users. it only iterates to the first user who is online then returns the count as “1” instead of “2”.
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) {
// change code below this line
let count = '';
for (let user in obj) {
if (obj[user].online === true) {
count++;
return count;
}
}
// change code above this line
}
console.log(countOnline(users));