6. list em all help


#1

var friends = {
bill: {
firstName: 'Bill',
lastName: 'Gates',
number: '(555) 555-555',
address: ['One Microsoft Way','Redmond','WA','98052']
}
};

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

I only get bill as a result


#2

I also have a question about his lesson. I tried to use object constructors, but i'm not sure what the proper syntax is to call them. Can someone help?

var friends = new Object();
friends.bill = new Object();
friends.bill.firstName = "Bill";
friends.bill.lastName = "Gates";
friends.bill.number = "(555) 555-5555"
friends.bill.address = ['address blah']
friends.steve = new Object();
friends.steve.firstName = "Steve";
friends.steve.lastName = "Jobs";
friends.steve.number = "(555) 555-5556"
friends.steve.address = ['address blah']
friends.abbie = new Object()
friends.abbie.firstName = "Grace";
friends.abbie.lastName = "Hopper";
friends.abbie.number = "(555) 555-5557"
friends.abbie.address = ['address blah']

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


#3

Correct Code:
var friends = new Object();
friends.bill = new Object();
friends.bill.firstName = "Bill";
friends.bill.lastName = "Gates";
friends.bill.number = "(555) 555-5555"
friends.bill.address = ['address blah']
friends.steve = new Object();
friends.steve.firstName = "Steve";
friends.steve.lastName = "Jobs";
friends.steve.number = "(555) 555-5556"
friends.steve.address = ['address blah']
friends.abbie = new Object()
friends.abbie.firstName = "Grace";
friends.abbie.lastName = "Hopper";
friends.abbie.number = "(555) 555-5557"
friends.abbie.address = ['address blah']

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

You were missing a semi colon and one opening and closing curly bracket also the ( is unnecessary around the friends object :smile:


#4

Thank you so much. I am confused by the semi colons. I was doing ruby before this and, I don't know why the semi colons get me every time!