7 search for a friend help


#1

Hello all! So I've been stumped on this my problem is that my error that i get is "Did you create a function called search?" but in i code my search is spelled right i even copied and pasted it from the instruction on the right side. Thanks in advance for any help :slightly_smiling:

var friends = {
bill: {
firstName: "Bill",
lastName: "gates",
number: "(151) 555 5555",
address:["29 Micosoft road","Redmond","WA","12345"]
},
steve: {
firstName: "Steve",
lastName: "jobs",
number: "(555) 505 1234 ",
address:["23 Apple road","Beachhill","CA","54321"]
}
};

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

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


#2

Hi try to call the function search()


#3

@ginganinja808

Also look here

It's not firends, it's friends.

It's firstName not firstname.

I noticed you log friends[key] on the browser and return friends[key] too. I don't think you need to do this twice.


#4

Thanks reply :slightly_smiling: when i correct my terrible grammar a new error comes up saying that "It looks like your search function doesn't return contact information for Steve."


#5

I am having the same issue, saying my code doesn't return the information for Steve. I didn't call for it, so I'm guessing that is the way the background checks to see if the code is correct, by calling for Steve and checking the results. I've included my search function code below:

var search = function (name) {
for (var firstname in friends) {
if (friends.firstname === name) {
console.log(friends.name);
return friends.name;
}
}
}

Any help on this problem would be appreciated. I've been trying for a couple of days now to solve it...


#6

@bitslayer98720
Please paste your full code (maybe there's an error having to look somewhere else)