Contact List Search Function


While trying to do this search function I get the error "Oops, try again. It looks like your search function doesn't return contact information for Steve." I added a else statement to see if key is retrieving any variables. It pulls bill and steve then errors out. Not sure whats wrong with my code please help haha.

var friends = {
    bill: {firstName:'Bill', 
    lastName: 'Gates', 
    number:"(905) 873-6472",
    address: ['One Microsoft Way', 'Toronto', 'ON', '12345']
    steve: {firstName:'Steve', 
    lastName: 'Jobs', 
    number:"(905) 873-6619",
    address: ['One Apple Way', 'Toronto', 'ON', '678910']
};// end of friends 

var list = function(friends){
    for(var names in friends){
}//end of list 

var search = function(name) {
    for(var key in friends) {
        if(friends[key].firstName === key){
            return friends[key];
            //added for trouble shooting
            // key is grabbing the name 
            // but nothing else
}// end of search function


It might be because you capitalized Steve in the first few lines but the very last line you just put it as a lower case steve?


That was not it but thanks to you I though of a new area of code to look at. I was calling key where I should have been calling the name function. Thanks for the help!!


I don't understand how this part works, could someone explain this to me?