Is it right that I am using variable as x.online?

Tell us what’s happening:

Is it right that I am using variable as x.online? Why I can`t sove this task?

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 result = 0;
      for(let x in obj){
        if(x.online == true){
          result+=1;
        }
      }
  return result;
  // change code above this line
}

console.log(countOnline(users));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.

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

Check out this fiddle and see what the problem in your code is (It isn’t what you titled this post. x.online is the correct way to access the data.

Also, check this out:

Updated fiddle, if you aren’t comfortable with the console yet (you should get really comfortable with it, but hey, I am a completionist):

http://jsfiddle.net/sqakjeom/1/

Do you mean that I can use like this if(x.online)?

Sorry, @camperextraordinaire is correct. I noticed a different error and focused on that instead of addressing your object of objects. You should take his hint about how to access the relevant member.