7.Search for a friend HELP


#1

var friends = {
bill: {
firstName: "Bill",
lastName: "Hauser",
number: "(651) 5479-000",
address:['one cheeseway', 'redmond','WA','2206']
}, //<--insert a comma here
steve: {
firstName: "Steve",
lastName: "Milas",
number: "(060) 4178-893",
address:['one cheeseway', 'redmond','WA','2206']
} , //<--insert a comma here
brian: {
firstName: "Brian",
lastName: "Caccichotti",
number: "(978) 322 5642",
address:['one cheeseway', 'redmond','WA','2206']
}, //<--insert a comma here
william: {
firstName: "William",
lastName: "Bergstrom",
number: "(651) 744 7900",
address:['one cheeseway', 'redmond','WA','2206']
}
};

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 [key];

}

}
}

I keep getting "Did you create a function called search? Please Help


#2

You have not defined key anywhere hence you will get a reference error


#3

should be: return friends[firstname];