7. Search for a friend


#1

Hi All,

Having some trouble with the final task. Code is here:
var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "123",
address: ['one microsoft way', 'richmond', 'usa'],
},
steve: {
firstName: "Steve",
lastName: "Jobs",
number: "987",
address: ['5 cupertino', 'brunswick', 'usa'],
},
};

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

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

};

any help would be appreciated!
thanks,


#2

in search function .
if (friends [key.steve === name)
your key missing the ' ] '.

and you have to make the function execute.
Add search('Steve') ;in the bottom.

In normal way,It also have mistake in this lesson.
Try to change first letter of friend's name to capital letter in friends object.
like that Bill:{}, Steve:{} .

my english is not good,but i hope it is helpful for u.: )