7. search for a friend


#1

It keeps telling me that search is not defined and that i need to create the search function. Can anyone tell me what I'm doing wrong?

code:

var friends = {

bill: {
    firstName: "Bill",
    lastName: "Coolio",
    number: 555-555-5555,
    address: ['1 Chalk Ln', 'Hollywood', 'CA', '90210']
    },
steve: {
    firstName: "Steve",
    lastName: "Steevo",
    number: 111-111-1111,
    address: ['2 Chalk Ln', 'Hollywood', 'CA', '90210']
    }

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

}

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


#2

I actually just found my mistake


#3

What was it? My code looks similar to yours and I'm encountering an error. Thanks.


#4

What was your mistake? I'm getting the same error.


#5

Remove the extra closing bracket