It needs an if statement or conditional ternary operator to find only the properties with online = true
count = 0
for (…) { if (obj[…][’…’] === …) { …++}} return count;
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 user.online
My solution would be to implement the if statement with your current algorithm