Cannot figure out what is wrong! 4/8 Contact List


#1

Hi,

I was doing quite good with Objects and Arrays.
Then I got stuck in this exercise.
As far as I am concerned the code is perfect but what it prints is "SyntaxError: Unexpected identifier".
Here is the code:

var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555"
        }
    steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: "(408) 555-5555"
        }
    yaara: {
        firstName: "Yaara",
        lastName: "Orlev",
        number: "(972) 555-5555"
        }
    vitto: {
        firstName: "Vittoria",
        lastName: "Mariani",
        number: "(+39) 555-5555"
        }
};

Can somebody help me to find my mistake?!
Thank you, Mattia


#2

Seems like your missing the ,s between your keys. Eventhough your values are "large" objects they are still values so you need to use a comma before going on with the next:

var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555"
        }, //<--
    steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: "(408) 555-5555"
        }, //<--
    yaara: {
        firstName: "Yaara",
        lastName: "Orlev",
        number: "(972) 555-5555"
        }, //<--
    vitto: {
        firstName: "Vittoria",
        lastName: "Mariani",
        number: "(+39) 555-5555"
        }
};

#3

Thanks! it worked perfectly!


#4

Has anybody done this with constructor? or am I supposed to complete this in literal?


#5

No seems like you can use constructor notation as well.