Building an Address Book, lesson 4 "Listing Everybody", TypeError: person is undefined


Like the title says, I'm getting a "your code threw the following error when trying to call list(): TypeError: person is undefined." I've read through the forums and have tried many different approaches for making this code pass the check, but all have failed (for me.) Here's what I've got:

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++); {

I appreciate any help I can get on this matter.


I believe that you're supposed to write contacts.length there, not contactsLength as the variable. Also, do NOT put semi colons after a loop before the first corresponding bracket.:smiley:


Thank you, ragezapper. I'm almost sure that semicolon gets me often, and I did look over the code many times, slowly. Our minds can play tricks on us. The same thing happened learning about elsif for Ruby. Our minds fill in an "e" after the "s", but when we go to use that in the code it doesn't work. =)

Other than that, I thought the reason for setting the variable contactsLength to contacts.length was so we could learn to use the variable in for loops? You helped me, and I thank you. Will keep an eye out, doubly so, for proper semicolon usage.