Search Steve :( help me please!


this is an error that i got
. "It looks like your search function doesn't return contact information for Steve"

var friends = {
    bill: {
        firstName : "Bill",
        lastName : "Gates",
        number : 12345678,
        address :['BCN street','american',24],
    steve :{
        firstName : "Steve",
        lastName : "Jobs",
        number : 12345679,
        address :['montblanc street','american',24],
    tom : {
        firstName : "Tom",
        lastName : "Hank",
        number : 12345698,
        address :['hollywood','american',24],
var list = function (friends) {
  for (var key in friends ){
  console.log (key);
var search = function (friends){
    for (var key in friends) {
        if (name === friends[key].firstName) {
            return friends[key];


the problem is in your function parameter:

var search = function (friends)

the parameter is what you are comparing with:

if (name

so in your case the function parameter should be friend, since friend is a placeholder variable which will hold a value the moment you call a function (the argument you pass into the function when calling)


thank you so much :smiley: it worked


do you also understand why it works?


at first i was thinking since i made the function (friends) and all names are inside that function so when i want to call the name i just put name in this if (name === friends[key].firstName) { to call it out. but i have to call the holder of those variables .


no, you just have access to the object anyway, the parameter is the name you want to search for. You seem to understand now


thanks to you :smile: