Help me with Iterate Through the Keys of an Object with a Statement

Tell us what’s happening:

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 count = 0;
for (let user in obj){
return count;
  // change code above this line


Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36.

Link to the challenge:

You are accessing online property wrong. won’t return anything. Make sure you need to go inside obj first like obj[user]

It needs an if statement or conditional ternary operator to find only the properties with online = true
count = 0
for (…) { if (obj[…][’…’] === …) { …++}} return count;

สล็อต :dy
สล็อตออนไลน์ :dy

You are basically telling count to add the value of online property to count variable.

for (let user in obj) {

This iterates through the most top level property. Meaning it selects Alan, Jeff, Sarah, Ryan properties of users object.

First, what your code is currently saying “add the value of online to count”.
For Alan, its saying count = 0 + false,
Jeff would be count = 0 + false + true
Sarah would be count = 0 + false + true + false
And so on.

You accessed the value of online correctly by doing

My solution would be to implement the if statement with your current algorithm

If ( {