What is wrong with this code? It says "Oops, try again. It looks like your search function doesn't return contact information for Steve."


#1


var friends = {
bill: {
firstName: "Bill",
lastName: "Thorton",
number: "(765) 869-7654",
address: ['42 East Redwood St', 'Charming','CA','99017']
},
steve: {
firstName: "Steve",
lastName: "Johnson",
number: "(765) 246-8435",
address: ['64 Clarence St','Charming','CA','99017']
}
};
var list = function(paramete){
    for(var temp in paramete){
        console.log(temp);
        }
    }

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


#2

Read carefully what your function should compare the argument to, does it really say the first name?


#4

Check your capitalisation. - I did exactly the same!


#5

Capitalization of what, the firstName fields? That would cause it to pass, yes, BUT it would be two wrongs making a "right". You're not supposed to be looking at the first name at all, something else is asked for.


#6

Yes we are; "If the argument passed to the function matches any of the first names in friends,"


#7

Ah. Right you are!
The previous one for the list function lists keys, this one matches the firstName field.


#8

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