CA not seeing my list(); function as existing


#1



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


Oops, try again.
It looks like your list function didn't console.log "Bob Jones". Did you remember to call list(); after creating it?


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];

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

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

list();


#2

@blogsurfer41468,

To use Array's length property
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length
you would have used

var contactsLength = contacts.length;

with which you have assigned the Array's contacts.length
to the variable contactsLength

Then in your FOR-loop setup you
either use

   for (i = 0; i < contacts.length; i++){

OR reffering to the variable contactsLength

   for (i = 0; i < contactsLength; i++){