I am trying to return contact info for "steve", but codecademy is telling me that it is not returning correctly.
It looks like your search function doesn't return contact information for Steve.
I am not able to find any error in this code. Can you help me with finding any syntax or logical errors in the search function that you can see?
var friends = {
bill: {
firstName: "bill",
lastName: "gates",
number :21415,
address: ["mcklsn", "wcnskln"]
},
Steve: {
firstName: "bill",
lastName: "gates",
number: 21415,
address: ["mcklsn", "wcnskln"]
}
};
var list = function (friends)
{
for (bill in friends)
console.log(bill);
for (steve in friends)
console.log(steve);
};
var search = function(name)
{
for (var i in friends)
{
if (friends[i].firstName === name)
{
console.log(friends[i]);
return friends[i];
}
else
console.log("contact doesn't exist!");
}
};