Oops, try again. Did you create a function called search?


#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.>
"Oops, try again. Did you create a function called search?"
It works just fine in the sandbox.

But the lesson itself won’t accept it.

I’m stuck.

Thanks

```

var friends = {
bill: {
firstName: “Bill”,
lastName: “Gates”,
number: “(206) 555-5555”,
address: [“2 M$ Wood”, “Bremerton”, “WA”, “00524”]
},
steve: {
firstName: “Steve”,
lastName: “Jobs”,
number: “(573) 369-2259”,
address: [“14 Derby”, “Oakbud”, “KY”, “77685”]
}
};
var list = function (obj) {
for (var key in obj){
console.log(key);
}

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

};


#2

@cavemanscorch,
At your list =function= you forgot a closing-curly-bracket-}
with which you would close it's FUNCTION-BODY
instead
you defined the search =function=
and then used an extra-closing-curly-bracket-} at the =end= of your code
causing the search =function= to be an integral part of your list =function=

friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555",
        address: ["2 M$ Wood", "Bremerton", "WA", "00524"]
        },
    steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: "(573) 369-2259",
        address: ["14 Derby", "Oakbud", "KY", "77685"]
        }
    };

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


list(friends);
search("Bill");
console.log( "== My End ==" );
console.log( "== All that is displayed now, is the course-checker ==" );