Im stumped on this address book exercise


#1


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


The list prints out twice when I want it to print the list once!
//Output:
Bob Jones
Mary Johnson
Bob Jones
Mary Johnson


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

list();


#2

It tells me to call the list() function at the bottom of the code and then it tells me to call printPerson() inside my for loop. Is this an error on the creators of this codeacademy exercise?


#3

The second printout is the lesson checker run result.


#4

Okay, thank you :slight_smile:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.