Finding that special someone


#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]);
	}
};
list();
/*Create a search function
then call it passing "Jones"*/
function search(lastName){
    var clength=contacts.length;
    for(var j=0; j < clength; j++){
        if(contacts[j].lastName===lastName){
            printPerson(contacts[j]);
        }
    }|
};
search("Jones");


#2

Please go through the below code and tell me where I am getting the error. I am getting error as "Oops! Try again. There was a problem with your syntax." Please help me!!!!!!!!


#3

on line 36:

}|

you got a vertical bar, causing syntax problems. Remove the vertical bar


#4

Thank you so much for your quick reply. Code is working now. :slight_smile: