Code works but why does it print twice to console


#1

This is my code. It works fine does its purpose. But why does it print twice to the console I get bob and mary names printed twice. I know in the previous exercise it says it will print twice to double check. But is this true for all exercises for address book?

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

#2

The lesson checker (SCT, Submission Correctness Test) runs our code in order to test it, so we see the output twice. So long as your expected output is there, you can ignore the rest.