Array of All Object Keys with Object.keys()

Tell us what’s happening:

IN THE OUTPUT THE ERROR IS ‘R is undefined’.

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
var newArr = [];
newArr.push(Object.keys(obj));
// change code above this line
}

console.log(getArrayOfUsers(users));


**Your browser information:**

User Agent is: <code>Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0</code>.

**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 aren’t returning newArr from your function. Try adding return newArr to the end of your code.

I’d agree that the error message could be made a lot clearer. The tests need some work.

1 Like

thank you @chuckadams