Basic Data Structures - Iterate Through the Keys of an Object with a for...in Statement

Tell us what’s happening:
Describe your issue in detail here.
hi there, my issue is that in the console apper “Undefined” when i write any number in result. Someone can explane me why ?
Your code so far

const users = {
  Alan: {
    online: false
  },
  Jeff: {
    online: true
  },
  Sarah: {
    online: false
  }
}

function countOnline(usersObj) {
  // Only change code below this line
let result = 0;
for (let users in usersObj) {
  if (usersObj[users].online === true){
    result++;
  }
}
  // Only change code above this line
}

console.log(countOnline(users));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 OPR/91.0.4516.95

Challenge: Basic Data Structures - Iterate Through the Keys of an Object with a for…in Statement

Link to the challenge:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.