Oops, try again. It looks like your search function didn't log "Bob Jones" to the console. Did you remember to call search after you defined it?


#1


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"*/
var search = function(lastName) {
for (var i = 0; i< contacts.length; i++) {
if (contacts[i].lastName === lastName){
    console.log(contacts[i].lastName);
}
}
}
search("Jones");


#2

this line:

console.log(contacts[i].lastName);

is incorrect, from the instructions:

Have the function run printPerson on the person if and only if the lastName property of the person matches the lastName argument.

so don't log to the console, instead call printPerson() when a match is found


#3

Thankyou for your valuable help, it work. I am very very great-full of you.


#4

good to hear :slight_smile: You're welcome :slight_smile:


#5