Cant find the error in the add function exercise


#1



https://www.codecademy.com/courses/building-an-address-book/0/6?curriculum_id=506324b3a7dffd00020bf661


syntax error that I cannot seem to find anywhere


var bob = {
    firstName: "Bob",
    lastName: "Jones",
    phoneNumber: "(650) 777-7777",
    email: "bob.jones@example.com"
};

var mary = {
    firstName: "Mary",
    lastName: "Johnson",
    phoneNumber: "(650) 888-8888",
    email: "mary.johnson@example.com"
};

var contacts = [bob, mary];

function printPerson(person) {
    console.log(person.firstName + " " + person.lastName);
};

function list() {
	var contactsLength = contacts.length;
	for (var i = 0; i < contactsLength; i++) {
		printPerson(contacts[i]);
	}
};

/*Create a search function
then call it passing "Jones"*/
var search = function(lastName) {
    var contactsLength = contacts.length;
    for (i=0 ; i < contactsLength ; i++) {
        if (lastName == contacts[i].lastName) {
            printPerson(conctact[i]);
        }
    }
};

search('Jones');

var add = function (firstName,lastName,phoneNumber,email) {
        var contacts.push ({
        firstName: firstName,
        lastName: lastName,
        email: email,
        phoneNumber: phoneNumber
    });
    
};
add('Dave','Smith','(999) 999-9999', 'davesmith@hyu.btb');
list();


#2

Check your add function; contacts.push shouldn't be a declaration.

Also, one of your references to contacts is spelt incorrectly, so have a look for that!


#3

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