The search feature in this code snippet seems to be causing some trouble. I suspect that the issue lies within the For...In loop, however, my knowledge of JavaScript is still pretty new. Here is the snippet:
var contacts = {
john: {
firstName: "john",
lastName: "smith",
number: 1,
address: ["1"]
},
jane: {
firstName: "jane",
lastName: "smith",
number: 2,
address: ["2"]
}
};
var displayList = function(list) {
for(var item in list) {
console.log(item);
}
};
var findContact = function(name) {
for(var contact in contacts) {
if(contact.firstName === name) {
console.log(contact);
return contact;
}
}
};
findContact("jane");