Nothing showing in the console despite correct code


#1


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

Hello Everyone,
So my code "works" seemingly, as it allows me to pass onto the next lesson, however nothing shows in the console, and I cannot continue my programming quest without validation from the box. Can anyone point out anything in my code that may potentially be obstructing the box from showing what it needs to show?


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 = {bob, mary}

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

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

list()


#2

The context of the function is person, not this.


#3

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