Very stuck "search for a friend"


#1

I continue to get the error did you create a function called search. heres my code;

var friends = {};
friends.bill = {
firstName: "Bill",
lastName: "Adkins",
number: "(302) 765-5631",
address: ['the end drive']
};
friends.steve = {
firstName: "Steve",
lastName: "Coker",
number: "(635) 255-5555",
address: ['the beginning drive']
}
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[firstName];
}
}
};
}
list(friends);
search("Steve");


#2

Do you understand what you wrote here means? I am asking about the syntax?


#3

I thought I was asking to return "Steve"


#4

Syntax for return:

var x = "Hello, world";
return x; //Returns 'Hello, world'

var y = 123;
return y; //Returns '123'

return "Hello, world"; //These are the same as
return 123; //the ones above, without using variables.

#5

okay that's great. You know what you have to output so add a closing brace after the last line here

and remove the closing brace before this line

Run it and see the output of your return


#6

Wow! that was it! Thanks rydan