Stuck on 6. We Made a friend!


#1

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

ReferenceError: fistName is not defined


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

/*Create a search function
then call it passing "Jones"*/
function search(lastName){
    var contactsLength = contacts.length;
    for(var j = 0; j < contactsLength; j++){
        if(lastName === contacts[j].lastName){
            printPerson(contacts[j]);
        }else{
            console.log("contacts not found");
        }
        }
};
search("Jones");

var add = function(firstName, lastName, email, phoneNumber){
    contacts[contacts.length] = {
        firstName: fistName,
        lastName: lastName,
        email: email,
        phoneNumber: phoneNumber
    }
};
add("Annie","T","annie@gmail.com", "(347) 123-1234");
list("Annie");


#2

Error message says pretty much everything.

Line 44:

firstName: fistName,

It should be firstName.


#3

Ahh thank you LOL wow


#4

You're very welcome :slight_smile:


#5

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