What's wrong with this?


#1

What's wrong with this?
Plz help me :smile:

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

}

};

search ("Jones");


#2

you just mistyped lastName :smile:

also, i don t think you need to return contacts[i];


#3

what a crazy mistake!!!!!! thnx alot :smile:


#4

n/p :wink: