Is there a bug in the program?


#1

In this activity, I tried to submit my code but it returned as "Did you create a function called search?". However, it is obvious that I did make a function called search. My code is as follows:
var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(696) 969-6969",
address: ['69 Microsoft Way', 'Redmond', 'Washington'],
},
steve: {
firstName: "Steve",
lastName: "Jobs",
number: "(969) 696-9696",
address: ['420 Apple Drive', 'Cupertino', 'California'],
}
};
var list = function(name) {
for (var i in friends) {
console.log(i);
}
}
var search = function(name) {
for(var key in friends) {
if(friends[key].firstName === Bill) {
console.log(friends[key]);
return friends[key];
}
}
};

search("bill");

Is this a bug in the system?


#2

See comments in code below:

var search = function (name) {
    for(var key in friends) {
        if (friends[key].firstName === name) { // change Bill to name
            console.log(friends[key]);
            return friends[key];
        }
    }
};
search("Bill"); // search for name as written in data, not key.

#3

thank you so much i had been stuck on this for a while