4. Listing Everybody - Works but something is wrong


#1



Hey everyone !
There's something wrong in my code but after trying some changes, I can't find what it is. The exercise is correct but the console display a "undefined" line after each of the good lines. So, I would like to know what can I do to have everything but these "undefined" lines.
Thanks :smiley:


function Person(firstName, lastName, phoneNumber, email) {
    this.firstName = firstName;
    this.lastName = lastName;
    this.phoneNumber = phoneNumber;
    this.email = email;
};

var bob = new Person("Bob", "Jones", "(650) 777-7777", "bob.jones@example.com");
var mary = new Person("Mary", "Johnson", "(650) 888-8888", "mary.johnson@example.com");

var contacts = new Array();
contacts[0] = bob;
contacts[1] = mary;

function printPerson(Person) {
    console.log(Person.firstName + " " + Person.lastName);
};

function list() {
    var contactsLength = contacts.length;
    for(i=0 ; i < contactsLength ; i++) {
        console.log(printPerson(contacts[i]));
    }
};

list();


#2

you just need to call printPerson(contacts[I]), no console.log


#3

Oh, thanks a lot, that's works :smiley:


#4

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