Contact list 5 Unexpected identifier


#1


Cotact list 5. Tossing in an array


I'm getting SyntaxError: Unexpected identifier and I have no idea why.


var friends = new Object();

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

var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555"
        address: ["One Microsoft Way","Redmond","WA","98052"]
    }
    steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: "(206) 666-6666"
        address: ["Seven Apple Road","Bluemond","CA","09163"]
    }
};


#2

property's inside the object should be separated by comma's (,):

number: "(206) 555-5555" // missing ,

they are missing in both the bill and steve object of your case. It also seems more syntax then needed. both this:

var friends = {
}

and:

var friends = new Object();

will create a friends object. Same for bill and steve


#3

Thanks, but I'm still getting the unexpected identifier error.

The new code:

var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555",
address: ["One Microsoft Way","Redmond","WA","98052"]
}
steve: {
firstName: "Steve",
lastName: "Jobs",
number: "(206) 666-6666",
address: ["Seven Apple Road","Bluemond","CA","09163"]
}
};


#4

you also need to separate the bill and and steve property with a comma, since they are property of friends:

address: ["One Microsoft Way","Redmond","WA","98052"]
    } // missing ,

#5

The code works now, thank you very much!


#6