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

Tell us what’s happening:

Creo que he resuelto el problema pero aun asi me devuelve error.

function countOnline(allUsers) {
// Cambia solo el código debajo de esta línea
let result = 0;
for(let allUsers in users){
if(users[allUsers][“online”] === true){
result++;
}
}
return result;

Your code so far

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

function countOnline(allUsers) {
  // Cambia solo el código debajo de esta línea
let result = 0;
for(let allUsers in users){
  if(users[allUsers]["online"] === true){
    result++;
  }
}
 return result;
  // Cambia solo el código encima de esta línea
}

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/128.0.0.0 Safari/537.36

Challenge Information:

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

I have a question for you, what is allUsers?

Your code is correct, except it doesn’t follow the requirements.

You are asked to use the allUsers function parameter, it is passed the users object. Use the parameter and not the top-level users object. You will have to adjust your variable names.