Building Address Book 4.Listing Everybody display


#1


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

This code works but it displays the contacts twice. Is it supposed to do that? How do I get it to display only once?


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

/*printPerson(contacts[0]);
printPerson(contacts[1]);*/

function list(){
    var contactsLength=contacts.length;

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


#2

Take away your

 list();

You already are printing the names of your contacts, calling 'list' prints them twice.