So, here is what I have now:
function countOnline(usersObj) {
// Only change code below this line
let count = 0;
for (let user in usersObj) {
console.log(user);
for (let online in usersObj[user]) {
console.log(online);
if(usersObj[user][online] === true) {
count = count + 1;
}
console.log(count);
return count;
}
// Only change code above this line
}
}
var usersObj = {
Alan: {
online: false
},
Jeff: {
online: true
},
Sarah: {
online: false
}
}
countOnline(usersObj);
But still I get errors:
// running tests The function
countOnline
should return
1
when the object
{ Alan: { online: false }, Jeff: { online: true }, Sarah: { online: false } }
is passed to it The function
countOnline
should return
2
when the object
{ Alan: { online: true }, Jeff: { online: false }, Sarah: { online: true } }
is passed to it // tests completed // console output Alan online 0 Alan online 0 Alan online 1 Alan online 0