"SyntaxError: Unexpected token {" Don't know what's wrong


#1

Not sure what's wrong here - I get:
"SyntaxError: Unexpected identifier" and "Oops, try again. There was a problem with your syntax."
Here's my code:

var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555",
address: ["234 6th Avenue", "Coastview", "WA", "98052"]
}
steve: {
firstName: "Steve",
lastName: "Gates",
number: "(555) 908-3937",
address: ["838 7th Street NE", "Albany", "NY", "23982"]
}
};
var list = funtion (friends) {
for (var firstName in friends) {
console.log(firstName);
}
};


#2

This is how the first bit of code should look. You can incorporate these changes into the second object as well.

var friends = {}
    friends.bill = {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555",
        address: ["234 6th Avenue", "Coastview", "WA", "98052"]
};

#3

Thank-you - know I'm getting "SyntaxError: Unexpected token {"
This is the code I have now:
var friends = {}
friends.bill={
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555",
address: ["234 6th Avenue", "Coastview", "WA", "98052"]
};
friends.steve={
firstName: "Steve",
lastName: "Gates",
number: "(555) 908-3937",
address: ["838 7th Street NE", "Albany", "NY", "23982"]
};

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

Not sure what's out of place?


#4

An easy enough mistake to make...

var list = funtion (friends) {

should be,

var list = function (friends) {

Also, it's a good idea to end statements with ;, including, var friends = {};


#6

It's an easy mistake with missing commas I also made. When you're listing different properties on your object, they are separated with commas so:

var friends = {
    bill: {
    },
    steve: {
    },
};