7. Search for a friend - "It looks like your search function doesn't return contact info for Steve"


#1

I've been reading through other threads trying to wrap my head around this and I feel like my understanding has improved but I can't figure out what's wrong with my code here.

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

My code:

var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Withers",
        number: "555-555-5551",
        address: ['1 Great Street' , 'SF' , 'CA', '94102']
        },
        
    steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: "555-555-5552",
        address: ['2 Great Street' , 'SF' , 'CA', '94102']
        },
        
    joel: {
        firstName: "Joel",
        lastName: "Raul",
        number: "555-555-5553",
        address: ['3 Great Street' , 'SF' , 'CA', '94102']
        }
    
    };
    
var list = function(object) {
    for (var key in object) {
        console.log(key);
    }
};

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

I'm pretty sure it's just an issue with the search function as I got to this point fine. What I'm thinking is I don't have clear in my head which words are placeholders and which should be specific (referring to the friends object, or a specific key).

Please help !!


#2

here:

if (friends[key].firstname === name)

bill and steve do not have a firstname property, property names are case sensitive.


#3

UGH. Lol

Thank you !!!


#4

Yep, programming is pretty unforgiving.


#5