4. listing everybody Need help


#1


Need Help :slight_smile:



TypeError: Cannot read property 'firstName' of undefined


Replace this line with your code. 
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);
}

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

list();


#2

here:

printPerson(contacts.length[i]);

contacts is the array, and i contains the index so to get to the person you do contacts[i], not sure what .length is doing in here


#3

lol thanks :smile: :smile_cat:


#4