Abit confused


#1

var friends = new Object();
friends.bill = new Object();
friends.steve = new Object();

friends.bill.firstName = "Bill";
friends.bill.lastName = "Gates";
friends.bill.number = "(204) 444 555";
friends.bill.address = ["Germay","Marburg","7"];

friends.steve.firstName = "Steve";
friends.steve.lastName = "Jobs";
friends.steve.number = "555326";
friends.steve.address = ["Germay","Marburg","1"]

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

this does work for me but the out put is something strange! -->
bill
steve
bill
steve

Im wondering is like that??? please sombode help me.
and a second question:
var list = function(friends) {
for (var bill in friends) {
console.log (bill);
}
};
why do we just use bill in console.log? isn`t it needed to add other friends too?
thanks in advance


#2

You assigned each friend to the name bill


#3

so how should I assign others too???


#4

You're iterating through all of them, so there aren't any others.

You can rename bill to friend in your loop to make more sense out of it.