4 Listing Everybody


#1

I am currently getting an error called: "Oops, try again. Your code threw the following error when trying to call list(): TypeError: Cannot read property 'firstName' of undefined."

Here is my current code so far for the entire 'Building an Address Book' project, and I really need help with this because I spent 1 1/2 hours trying to figure this out:

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 list = function() {
for (i = 0; i < contacts.length; i++); {
console.log(printPerson(contacts[i]));
}
};


#2

console.log(printPerson(contacts[i]));

Just get rid of the console.log statement and leave everything else.

printPerson(contacts[i]);