Tossing in an array


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-3bmfN/0/5?curriculum_id=506324b3a7dffd00020bf661


it say "SyntaxError: missing before statement"
i really dont know where the error

var friends = {}
    friends.sadam: {
        firstName: 'Sadam',
        lastName: 'Husen',
        number: '7091291',
        address: ['qwerty', 'baghdad', 'iraq']
    }
    friends.bill: {
        firstName: 'Bill',
        lastName: 'Gates',
        number: '021332012',
        address: ['ggwp', 'California', 'USA']
    }
    friends.steve: {
        firstName: 'Steve',
        lastName: 'Jobs',
        number: '88100221',
        address: ['asdf', 'Montreal', 'Canada']
    }


#2

there are two ways to approach this, declare the friends object like you did:

var friends = {}

and then add objects to friends:

friends.sadam: {
        firstName: 'Sadam',
        lastName: 'Husen',
        number: '7091291',
        address: ['qwerty', 'baghdad', 'iraq']
    }

however, if you choice this way (option 1) you should use friends.sadam =, given it is a object declaration. If you nest the object directly in the friends object like in the information of the exercise, you can use a colon


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.