Unexpected identifier


#1
function add(firstName, lastName, email, phoneNumber) {
    var newContact = {
        var contactsLength = contacts.length;
        this.firstName = firstName;
        this.lastName = lastName;
        this.email = email;
        this.phoneNumber = phoneNumber;
        contacts[contactsLength] = newContact;
    }
};

whenever i execute this it says "SyntaxError: Unexpected identifier"
why?


#2

Hi @ethanator_hoffmaster,
Hint:

var contactsLength = contacts.length;

How can this statement be inside an object literal definition (of newContact)?