Neil Sammons
Neil Sammons

Reputation: 1

Having trouble with my string. Error pops up saying "unexpected string"

var contacts = {
    'addressBook' : [
    {
        'name': 'hillisha'
        'email': '[email protected]',
    },
    {
        'name': 'neil'
        'email': '[email protected]',
    },
    {
        'name': 'brian'
        'email': '[email protected]',
    },
    {
        'name': 'matt'
        'email': '[email protected]',
    },
    {
        'name': 'mike'
        'email': '[email protected]',
    }

    ]
};

error pops up saying unexpected string. Not sure why and need help. I am trying to just run a rather simple loop and it isn't expecting string.

Upvotes: -1

Views: 43

Answers (1)

Luan Nico
Luan Nico

Reputation: 5917

You are missing your commas after each 'name' element on the objects inside the array. Note that that the last comma, after 'email', is actually optional.

Upvotes: 2

Related Questions