7. search for a friend


#1

i keep getting this error: Oops, try again. It looks like your search function doesn't return contact information for Steve. i have the output

bill
steve
No user found
No user found
No user found
No user found
No user found
No user found
No user found
No user found
No user found
No user found
No user found
No user found
No user found
No user found
No user found
No user found
No user found
No user found
No user found

Help would be appreciated. Thanks in advance.

var list = function (friends) {
{
for (var key in friends ) {
console.log(key);
}
}
};
var list = function (friends) {
for (var key in friends) {
console.log(key);
}
};
var search = function(friends) {
for (var key in friends) {
if ([key].firstName === name) {
console.log(friends[firstName]);
return (friends[key]);
}
else {
console.log("No user found");
}
}
};
list(friends);
search("Steve");


#2

On this line, You should be checing for the firstName key

like this,

if(friends[key].firstName === name)

But in doing so you would need to change the console.log as well. :slight_smile:


#3

3 posts were split to a new topic: Telling me fix this fix that won't help because I dont understand a single thing


#6

Check your argument for the search function. Hint: how is name being defined in the for/if statement in the search function?


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.