List Em All, Help and explanation


#1

I don't know whats wrong. ??
var friends = {
bill: {
firstName:"Bill",
lastName:"Gates",
number: "(092)555 -5555",
address: ['One Microsoft way', 'Redmond','WA','98052']
}
steve: {
firstName:"Steve",
lastName:"Jobs",
number: "(092)555 -5666",
address: ['Sawtell blvd', 'Culver city','CA','90052']
}

};

var list = function(friends){
for (var firstName in friends) {
console.log(list);

    };
}

#2
var list = function(friends){
    for (var firstName in friends) {
        console.log(list);

    };
}

well list is the name of your function so you'll see [Function] the number-of-keys-in-your-friends-object times. The for in loop works like this that it runs key times and in each run the variable before the in has the stringified version of a key name e.g.

"steve"

So if you want to see the keys use firstName and to see the values you can use square bracket notation friends[firstName]


#3

I did it thanks... you saved me. :smile: