Listing Everybody TyperError Person is undefined


#1


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

Bob Jones
Mary Johnson
Bob Jones
Mary Johnson
TypeError: person is undefined


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


#2

HI this part

for(var  x = 0; x <= contacts.length; x++)

you should remove the = to <=


#3

Hi, i dont really understand wich part i have to change.
can you mark it with red or something like that?
the other thing is, i got this error : "TypeError: Person is undefined"
Thanks :smiley:


#4

Sorry.... it's in the for loop

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

instedd of x <= contacts.length you should put x < contacts.length just remove the = to <=


#5

Ohhhh! :D,
Ok Thanks it works now.
:thumbsup: