4. Listing everybody



"Oops, try again. It looks like your list function didn't console.log "Bob Jones".

Did you remember to call list(); after creating it?" I really don't have the slightest idea on my mistake so could anyone please help me? I would also appreciate if someone could explain me if in the function "list" we are calling printPerson(contacts[i]); in order to use the output of the function with the data from contacts, am I right?

I also don't completely understand why are we using the person parameter in the printPerson function.

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.Length
    for (var i = 0; i < contactsLength; i++) {


If you are checking the length of your array, you need a lowercase l for contacts.length.

When you are defining a function, think of its parameter as a variable or even as a placeholder. You could have written 'bananas' instead of 'person'. It doesn't matter since the function isn't being asked to execute until later on in your code (in your list function loop) where you swap in 'contacts[i]'.

Read more here:



Thank you a lot man, my mistake was with contacts.length I got confused and wrote the variable as well as the value of the variable with l uppercase. I am using the person parameter because as far as I understand the word person, as it is used in the console.log and it is nos a declared variable, is should be written as a parameter in order to not get an error, am I right?


When declaring a function that needs a defined variable, give the function a parameter. Then when you call that specific function to execute(like you did with printPerson) give the function the parameter it needs.


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