I'm working my way through a tutorial and I have hit a snag.
I created this object and I'm trying to loop through and print the first names of the entries. I thought it was working, but then I noticed that when I change 'firstName' in my for loop to 'number' or 'lastName', it still writes the first names to the console.
Can anyone shed some light for me? Thanks!
var friends = {
bill:{
firstName:"Bill",
lastName:"Gates",
number:"617-333-3333",
address:["One Microsoft Way", "Redmond", "WA", "98052"]
},
steve:{
firstName:"Steve",
lastName:"Jobbs",
number:"617-222-2222",
address:["15 Idontknow Street", "No Idea", "NO", "33333"]
}
};
var list = function(friends){
for (var firstName in friends) {
console.log(firstName);
}
}