Evening all,
I’m having a little trouble with
Here is my code:
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 counter = 0;
let user = '';
for (user in obj); {
if(obj[user].online == true){
console.log(user);
counter ++;
console.log(user);
}
}
return counter;
// change code above this line
}
console.log(countOnline(users));
At the moment, I am only logging 1 for the countOnline function. I wanted to check my input with further logs on the user, but when I checked my console it returns “Ryan” and “Carl”, which isn’t even in the object.
My questions are:
- Why am I skipping over Jeff?
- Where did Carl come from?
Thanks in advance.