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

Tell us what’s happening:
I have seen the hints and y’alls questions on this already but I really don’t get how that answer is the answer. If anyone could explain the outcome to me i would really appreciate it.

Thank you

Your code so far

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

function countOnline(usersObj) {
  // Only change code below this line

  // Only change code above this line
}

console.log(countOnline(users));

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36

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

Link to the challenge:

What code have you tried? It is easier to explain if we see what you do know.

I got as far as

for (let user in users) {

But I mainly just don’t understand how you are supposed solve this one…

Do you know how you would do it with a plain for loop?

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