7. Search for a friend


#1

here is my code. getting error message "did you create a function called search?"

var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(555) 555-5555",
address: ['One Microsoft Way', 'Redmond', 'WA', '98052']
},
steve: {
firstName: "Steve",
lastName: "Jobs",
number: "(000) 000-0000",
address: ['One Microsoft Way', 'Redmond', 'WA', '98052']
}
};
var list = function(friends) {
for (var i in friends){
console.log(i);
}
};
var search = function(friends) {
for(var i in friends) {
if(friends[i].firstName === Bill){
console.log(friend[i]);

        return friends[i]
    }
    }
    };

#2

There are two syntax errors in body of your function, you have to fix them :slightly_smiling:

Take a look at these lines:


if(friends[i].firstName === Bill){
console.log(friend[i]);

Variables friend and Bill are simply undefined. Remember that Bill references an object called Bill, but "Bill" is just a plain string value.