Tell us what’s happening:
I’m stuck on this challenge and the link to get a hint is broken for me (404 not found). I think I have the counter going but it’s returning 1. I’m sure that var i has something to do with it, but I was understanding for/in to be iterating on its own.
Your code so far
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
var i = 0;
for (let user in users) {
var onlineCount = 0;
if (obj[user].online == true) {
onlineCount++;
}
i++
}
return onlineCount;
// change code above this line
}
console.log(countOnline(users));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/-iterate-through-the-keys-of-an-object-with-a-for---in-statement/