Search for a Friend Error: "It looks like your search function doesn't return the contact information for Steve


#1


https://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/7?curriculum_id=506324b3a7dffd00020bf661


Getting the error message that my search function doesn't return steve. If I put "Bill" as the parameter, it works just fine. However with "Steve" as the parameter all I get for out put is :

steve
bill
{ firstName: 'Bill',
lastName: 'Rogers',
number: '444-444-444',
address: [ '111 bill Drive', 'Lexington', 'SC', '29073' ] }

var friends = new Object();

friends.steve = new Object();
friends.bill = new Object();

friends.steve.fistName = 'Steve';
friends.steve.lastName = "Rogers";
friends.steve.number = "555-555-5555";
friends.steve.address = ['111 Steve Drive', 'Lexington', 'SC', '29073'];

friends.bill.firstName = "Bill";
friends.bill.lastName = "Rogers";
friends.bill.number = "444-444-444";
friends.bill.address = ['111 bill Drive', 'Lexington', 'SC', '29073'];

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



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

search("Steve");


7. Search for a friend, expected Steve, got Bill :)
#2

I guess the ideal parameter to call for the search function should be this:

search("firstName");


#3

Remember to log contact info on lines 28 and 29. I just logged and returned the number and address.


#4

SyntaxError: Unexpected string


#5

Check the spelling of firstName.


#6

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