Iterate Through the Keys of an Object with a for...in Statement Once more, with feeling

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/

Loops can be tricky. Pay attention to where you’re creating the variable onlineCount. Compare it to the variable i. Also, do you really need i?

You are setting onlineCounter to 0 at every iteration of your for…in loop, so t will never go higher than 1

Thank you! No, I didn’t need i, or I didn’t need my new variable.