4.Adding Properties


#1

Here is my code:

var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555"
}
steve: {
fistName: "Steve",
lastName: "Jobs",
number: "(408) 666 6666"
}
};

I am pretty sure I have done what it asked me but its getting: SyntaxError: Unexpected identifier.

Could anyone help me out with what I am doing wrong here?


#2

add a comma before this line right after this


#3

I was having the same problem too, but adding a comma after this block solved it:

bill = {
//firstName...
//lastName...
//number...
}

Thanks @rydan.


#4

Why does putting a comma there fix it? the example that they give you doesn't have a comma. Maybe I am missing the point there.


#5

Because each key and value needs a comma unless its not the last key.
here, "friends " object's first key is bill and next is steve.
So, a comma is required after bill.


#6

Think of it in these terms:

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