var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555",
address: ['One Microsoft Way','Redmond','WA','98052'],
},
steve: {
firstName: "Steve",
lastName: "Jobs",
number: "(408) 555-5555",
address: ['1 Infinite Loop','Cupertino','CA','95014']
}
};
var list = function(friends) {
for (var i in friends) {
console.log(friends[i]);
}
};
I'm asked to log the names of the two objects to the console, but I'm confused about how to do this. Codecademy doesn't make it clear enough for me to understand. Can you? Desired output:
bill
steve
note: i do NOT want friends[i].firstname, I want the names of the objects friends[i].
It should be:
This is because
for...inloops through the keys of the object.Also, I suggest a different variable name, such as
friendinstead ofi, becauseiusually means a number or index.