Iterate Through the Keys of an Object with a Statement -- help

Tell us what’s happening:

What wrong am I doing here?

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 users){
return count;
  // change code above this line


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:

Inside the for loop, user is just a string like “Alan” or “Jeff”. Those strings will not have an “online” property.

You need to reference the main object (users) in some way while utilizing this user string which is a key of the users object.

HINT: Think nested objects.


Not looked at the actual question, just noticed you’re not referencing the function’s argument obj either