Tell us what’s happening:
I feel embarrassed to even share my code at this point. I’ve tried so many things that I don’t even know what code has been the closest one to the solution. I just can’t figure this one out!
Seems so easy, at the same time so frustrating not to figure it out this far. What an impotence feeling. Please if someone could help, not just with the code but also with explaining the reason behind it. I would greatly appreciate that. Thanks
**The exercise asks **
We’ve defined a function, countOnline
; use a for…in statement within this function to loop through the users in the users
object and return the number of users whose online
property is set to true
.
function countOnline(obj) {
// change code below this line
// change code above this line
}
console.log(countOnline(users));
**Your browser information:**
User Agent is: <code>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36</code>.
**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