Doesn't recognize function


#1



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


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


var friends = {
    yechiel: {
        firstName: "Yeciel",
        lastName: "Shulman",
        number: "(314) 727-8055",
        address: ["USA", "Missouri", "Univercity City", "Amherst", "8055"]
    },
    gavin: {
        firstName: "Gavin",
        lastName: "Kornblum",
        number: "(314) 725-8624",
        address: ["USA", "Missouri", "Univercity City", "Owner Mansion"]
    }
};

var list = function(n){
    for (var key in friends) {
        console.log(key)    
    }
}

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


#2

When you get mystery errors you may have to find out what's wrong yourself. Test your code, see if it does what the instructions describe.


#3

Apparently, it doesn't let you use other names besides Steve Jobs and Bill Gates


#4

There's that as well, but it probably told you that after repairing your function, right? Because trying to use your code right now:

console.log(search('Yeciel'));

results in:

/tmp/js/codecoder18935.js:23
    for(var key in object) {
                   ^

ReferenceError: object is not defined

#5

Ok, I have been looking at this for some time now and fpr whatever reason, I can't figure out why I get > ReferenceError: search is not defined. Have a look and enlighten your poor sister in arms. (I know I like my statements airy, so don't laugh at my use of {}.

`var friends =
{
bill:
{
firstName: "Bill",
lastName: "Door",
number: "072568438",
address: ['23 Rich Avenue', '25472', 'Never Land']
},
steve:
{
firstName: "Steve",
lastName: "Work",
number: "07256865438",
address: ["23 Rich Avenue", "25472", "Never Land"]
},
};
var list = function (friends)
{
for (var key in friends)
{
console.log(key);
}
var search = function (name)
{
for (var key in friends)
{
if (friends[key].firstName === name)
{
console.log(friends[key]);
return friends[key];
}
else
{
console.log "No matches found";
}
}
};
};

list(friends);
search("Steve");`


#6

function f() {
    var x = 5;
}

console.log(x);  // error, x has not been defined in this scope