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

Tell us what’s happening:

Please help

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 are given a parameter called obj. Change your code to use it.

1 Like

Object.keys() returns an array whose elements are strings corresponding to the properties found in the object.

if your question is why this didn’t work, it is because users is not passed into the function. the variable passed is’ obj’.