Did you remember to call list() ERROR


#1


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


/* Interpreter returns same message. Please advise..
Oops, try again. It looks like you didn't log "tim tom" to the console. Did you remember to call list() after adding your new contact?*/

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() {
	contactsLength = contacts.length;
	for (var i = 0; i < contacts.Length; i++) {
		printPerson(contacts[i]);
	}
}

/*Create a search function
then call it passing "Jones"*/

function search(lastName){
    contactsLength = contacts.length;
    for(var i=0;i<contacts.length;i++){
        if(contacts[i].lastName===lastName){printPerson(contacts[i])}
        
        
        };
    
    };
    
    
    
    
    
    search("Jones");
    
    
    function add(firstName, lastName, email, phoneNumber){
object = {
firstName: firstName,
lastName: lastName, 
email: email, 
phoneNumber: phoneNumber
};
contacts[contacts.length] = object;
};

add("tim", "tom", "timtom@example.com", "32874683275");

list();


#2

Does "tim tom" get printed when you call list ? If not, should it have? And if it should have, which steps should have happened to result in that having been printed? Did those steps happen? Add some prints and find out where it went wrong in those steps.


#3

I think you meant to leave out the period between contacts and Length.


#4

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