HI I am still having problem with my code with the example you gave @shimphillip it states that object is undefined. What am I doing wrong cause I write return object.keys(obj); but object is said to be undefined.
In order to get keys of any object the syntax is Object.keys(<object_name>). This returns an array.
In this challenge we have a nested Object,meaning we have keys which also contains objects and we need to list them all.
Here is the function that I wrote to get all the keys:
function getArrayOfUsers(obj) {
// change code below this line
let newArr = [];
for(let user in obj){
newArr.push(user); //Here I am also adding the first level keys (Alan, Jeff, Sarah and Ryan with each iteration.
newArr.push((Object.keys(obj[user]))); //Here I am adding the keys of Alan, Jeff, Sarah and Ryan with each iteration
}
return newArr; //Returning the array to calling function.
My brain just said “No, it’s not going to be that simple,” and then just said what the heck are you supposed to do here?! Haha, I’ve got to stop overestimating a challenge on here.
i have done the same but used console.log instead of return and did not work, just noticed how it matter to use return and not console.log!
im wondering whats the difference between both!