Search a friend , Get stuck!


#1

Code is not working, don't know why?
Getting err msg : Oops, try again. It looks like your search function doesn't return contact information for Steve.

var name = prompt("To whom you are searching for?");
var friends = new Object();
friends.bill = new Object();
friends.bill.firstName = "Bill";
friends.bill.lastName = "Gates";
friends.bill.number = "(555) 555-5555"
friends.bill.address = ['address blah']
friends.steve = new Object();
friends.steve.firstName = "Steve";
friends.steve.lastName = "Jobs";
friends.steve.number = "(555) 555-5556"
friends.steve.address = ['address blah']

var list = function(friends) {
for (var firstName in friends) {
console.log(firstName);
}}
var search = function(friends) {
for (var firstName in friends) {
if (friends.firstName === name) {
console.log(friends.firstName);
return friends.firstName;
}
else
{
console.log("Sorry! Not a friend of mine.");
break;
}
}
};

search();

#2

@berdimyrat,
Look here for an explanation
object
function
for-in-loop
list-function
search-function
http://www.codecademy.com/forum_questions/545275fd8c1ccc8e3e000a23#comment-5457b12c9c4e9d87cb00003f


#3

Thank you I have done it... Thanks.