Lesson 6 We Made a friend help!


#1



ReferenceError: yash is not defined


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

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

function add (firstName, lastName, email, phoneNumber) {
    contacts[contacts.length] = {
        firstName: firstName,
        lastName: lastName,
        email: email,
        phoneNumber: phoneNumber
    }
    contacts[contacts.length] = contact;
};

add("yash", "p", "abc@gmail.com", 1234);
list();


#2

Ok so, as far as I can tell, from looking over your code, this seems to be the only thing I could find that is wrong. You only need bob and mary in this contacts list not yash.


#3

nvm, problem is solved :slight_smile:


#5

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