Contact list input method - search friend name



I used the other method taught in a previous section to enter contact info for this exercise. It appeared to work ok up until part 7 where I am required to create a search function. Then I get an error message stating "Oops, try again.
It looks like your search function doesn't return contact information for Steve."

It seems the problem is with how I have entered the objects since when I use the object code given in the "what you will be building" section, my search function seems to work ok. Can anyone see where I am going wrong? I am struggling and feeling a deep sadness.

//the problem code

var friends = {};
    friends.bill = {}
        friends.bill.firstName = "Bill"
        friends.bill.lastName = "Gates"
        friends.bill.number = "0121 do one"
        friends.bill.address = ["One Yewcant Av.", "My Address", "America Maybe"]

    friends.steve = {}
        friends.steve.firstName = "Steve"
        friends.steve.firstName = "Jobs"
        friends.steve.number = "0870 you cant have my number bro"
        friends.steve.address = ["The Mansion", "Canta Fjoord", "Denmark"]

/* from here below appears ok when I replace the above with the following:

var friends = {};
friends.bill = {
  firstName: "Bill",
  lastName: "Gates",
  number: "(206) 555-5555",
  address: ['One Microsoft Way','Redmond','WA','98052']
friends.steve = {
  firstName: "Steve",
  lastName: "Jobs",
  number: "(408) 555-5555",
  address: ['1 Infinite Loop','Cupertino','CA','95014']
}; */

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



Search looks for a name in friends objects, not a key in friends.



Hi, thanks for the reply. I changed that around and it still gives the same error.


print out the friends and see for yourself if there's anyone with first name Steve


Hahaaaa! I got it.

So stupid too. Two entries for firstName - so Steve's first name was replaced as Jobs. Thus no Steve.

Thanks for the help.