Generate an Array of All Object Keys with Object.keys()! help

Tell us what’s happening:

PLease give me a solution to this

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 getArrayOfUsers(obj) {
  // change code below this line
Object.keys(users);
  // change code above this line
}

console.log(getArrayOfUsers(users));

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:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/generate-an-array-of-all-object-keys-with-object-keys

You’re passing users instead of obj.

function getArrayOfUsers(obj) {
  // change code below this line
Object.keys(obj);
  // change code above this line
}

Still wrong

You need to return the result from your function. Right now your function is returning nothing.

1 Like

solution

function getArrayOfUsers(obj) {
// change code below this line
return Object.keys(obj);
// change code above this line
}

1 Like