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

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

#1

Tell us what’s happening:

Dont understand how to get all what is inside. something is missing and dont understand what

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(obj);

  // 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/68.0.3440.106 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


#2

If you read the instructions, you should understand that Object.keys(obj) will return an array with the properties names of obj. That array would be exactly what the challenge is expecting your function to return, so you need to return this array.


#3

In blow, I pass the test. Bu I could not understand this part of Object.keys(). I read the instructions. I need return an array. But why is this correct ?

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

console.log(getArrayOfUsers(users));

#4

Read through the documentation of Object.keys and see what value it returns.