I'm lost in my code


#1


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


Oops, try again. Did you create a function called search?

<do not remove the three backticks belo
var friends = {
Bill: {
firstName: "Bill",
lastName: "Wood",
number: "374-3158",
address: ['Montreal','Quebec','Canada']
},
Steve: {
firtsName: "Steve",
lastName: "Roux",
number: "728-2925",
address: ['Quebec','Quebec','Canada']
}
};
var list = function(friends){
for(var key in friends){
console.log(key);
}
};
list();
var search = function(friends){
for(var key in friends){

    if(key === Bill ){
        console.log(key);
    }else if(key === Steve){
        console.log(key);
    }else{
        console.log("Pas dans la liste");
    }
}

};
search("Bill");

`


#2

I'm not sure you read the question properly. It states "If the argument passed to the function matches any of the first names in friends, it should log that friend's contact information to the console and return it."

So this makes you search function look something like this.

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

#3

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