Help w/ Statement

Tell us what’s happening:
Cannot seems to get this right. Can anyone tell me what I am doing wrong? Basic data structures statement.

Your code so far

function countOnline(usersObj) {
// change code below this line
let number = 0;
for (let user in usersObj){
  if (usersObj[user][online] == true){
} return number;
// change code above this line

Your browser information:

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

Challenge: Iterate Through the Keys of an Object with a for…in Statement

Link to the challenge:

What is online in your code?

Your logic for the loop works nicely. The problem with your code is the way that you’re using the bracket notation. When you’re using bracket notation, you have to access a string, so the conditional statement will need to look like this:

if (usersObj[user]['online'] === true) {

Also, if you log the value of user, you’ll see that it is a string as well, so that’s consistent. Alternatively, you could use dot notation to access that property like so:

if (usersObj[user].online === true) {


Worked! Thanks a bunch, man.