ReferenceError---search for a friend


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

https://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/7?curriculum_id=506324b3a7dffd00020bf661#
<In what way does your code behave incorrectly? Include ALL error messages.>
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”);

<do not remove the three backticks above>

#2

hi ,

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

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”);