ReferenceError---search for a friend


#1


https://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/7?curriculum_id=506324b3a7dffd00020bf661#

Reference Error: bill is not defined


var search = function (friends){
    for (var firstName in friends){
        if (friends[bill,steve,sherry].firstName === ["Bill","Steve","Sherry"]){
            console.log (friends[lastName, number, address]);
            return friends[steve,bill,sherry];
        }
    }
};

search ("Bill");


#2

hi ,

var search = function(name) {
for(var x in friends) {
if(friends[x].firstName === name) {
console.log(friends[x]);
return friends[x];
}
}
};

search("Bill");


#3

But it still says bill is not defined

var search = function (name){
for (var firstName in friends){
if (friends[bill,steve,sherry].firstName === name){
console.log (friends[bill,steve,sherry]);
return friends[bill,steve,sherry];
}
}
};

search ("Bill");


#4

you should not use "FirstName" for "var" , it's a little bit misleading lol. And replace "[bill,steve,sherry] by the name name of the var.

var search = function(name) {
for(var myVar in friends) {
if(friends[myVar].firstName === name) {
console.log(friends[myVar]);
return friends[myVar];
}
}
};

search("Bill");