Thanks for having a look at my question! I'm trying to complete the JavaScript course in codecademy and this has me stumped. I can't even find help in the codecademy forums. I am trying to figure out why "Bob Jones" isn't logged to the console. Any help is greatly appreciated. Here is my code:
var bob = {
firstName: "Bob",
lastName: "Jones",
phoneNumber: "(650) 777-7777",
email: "[email protected]"
};
var mary = {
firstName: "Mary",
lastName: "Johnson",
phoneNumber: "(650) 888-8888",
email: "[email protected]"
};
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 i = 0; i<contactsLength; i++){
if(lastName === contacts[i].lastName){
printPerson(contacts[i]);
}
}
};
search("Jones");