Tell us what’s happening:
my code isn’t working and the given solutions aren’t, either. any advice?
Your code so far
let counter = 0;
for (let user in obj) {
if (obj[user].online === true) {
counter++;
}
}
return counter;
function countOnline(usersObj) {
// change code below this line
let counter = 0;
for (let user in obj) {
if (obj[user].online === true) {
counter++;
}
}
return counter;
// change code above this line
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36
.
Challenge: Iterate Through the Keys of an Object with a for…in Statement
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-the-keys-of-an-object-with-a-for...in-statement