I’m currently on the same unit and may be wrong, but let me try to break it down plainly to the best of my understanding.
Take a look the code I used (which passed the lesson):
var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "6888 8899",
address: ["1 Marina Boulevard", "Singapore", "018989"]
},
steve: {
firstName: "Steve",
lastName: "Jobs",
number: "5678 5678",
address: ["Apple Campus", "Cupertine", "California", "95014"]
},
ron: {
firstName: "Ron",
lastName: "Weasley",
number: "7890 7890",
address: ["The Burrow", "Ottery St. Catchpole", "Devon", "32445"]
},
sirius: {
firstName: "Sirius",
lastName: "Black",
number: "3456 3456",
address: ["12 Grimmauld Place", "Islington", "London", "237346"]
}
};
var list = function(friends) {
for (var person in friends) {
console.log(person)
}
}
The console result:
bill
steve
ron
sirius
Explanation:
Although the instructions may seem somewhat abstruse (I was a little confused), basically what we’re supposed to do with the list function is to simply print a list of all the friends. Meaning print out the keys of the second-level objects (the persons) stored inside your ‘friends’ object.
I wrote that part like this:
var list = function(friends) {
for (var person in friends) {
console.log(person)
}
I used “person” as my placeholder word. In general when writing code it’s good to use words that are easy to understand semantically, that make sense in plain English.
What happens here is the for loop cycles through all 4 objects inside ‘friends’, and prints out each of the keys I assigned them. It results in this:
bill
steve
ron
sirius
Notice they are not capitalised—because it’s not the firstName key that we are printing.
Further explanation of keys:
You could think of all these objects here as a hierarchy of smaller boxes nested within bigger boxes. A key is akin to a label on a box, while values are like the contents of the box.
Level 1 — I have a main object (big box) with a key of ‘friends’.
Level 2 — Inside ‘friends’ are 4 objects (medium boxes): with the keys of “bill”, “steve”, “ron” and “sirius”.
Level 3 — Inside each person’s medium-sized box are several objects (small boxes) with keys like “firstName”, “address” etc.
Level 4 — Each small box contains one or more values.
Hope this helps! If anyone can correct my understanding please go ahead 