6/6 List not working after Add


#1

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

I keep getting that my contact isn't added and that I am not calling the list function. Or that the function isn't working. Could someone tell me what they see and I'm not.

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);
}

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

var search = function(lastName) {
    for(var i = 0; i < contactsLength; i++) {
        printPerson(contacts[i]);
    }
};

var add = function (firstName, lastName, email, phoneNumber) {
    contacts[contactsLength] = {
        firstName: firstName,
        lastName: lastName,
        email: email, 
        phoneNumber: phoneNumber 
    };
};

add("Why", "Aren't", "you@added.yet", "555-555-5555");
list();


#2

because var contactsLength = contacts.length; is not inside the list function, contactsLength will stay 2, so don't get to the third item in array


#3

Thank you so much you beautiful person.


#4