Iterate Through the Keys of an Object with a for...in Statement cc

Tell us what’s happening:

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
  let userOnline = 0;
for (let user in obj, userOnline++) {
  return Math.abs(userOnline);
}
  // change code above this line
}

console.log(countOnline(users));

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.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

you can’t do this - the loop doesn’t work if you do this, you can have only the let user in obj part there

then, second thing - if you put a return statement inside a loop you can avoid the loop as the retunr statement will return a value from the function as soon as it is met and the loop would just do the first iteration