Search for a friend, prints steve twice


#1



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


My code prints steve twice for some reason? I can't correct it no matter what I change.


ar friends = 
{
    bill:{
        firstName: "Bill",
        lastName: "Gates",
        number: "503-234-6744",
        address: ['microsoft way'],
        },
    steve:{
        firstName:"Steve",
        lastName: "Jobs",
        number: "324-525-6642",
        address: ['Apple Street'],
        }
}
 var list = function(friends)
 {
     var search = function(name)
   {
       for(var key in friends)
      
       {
           if(friends[key].firstName === name) 
           {
               console.log(friends[key]);
               return friends[key];
           }
       }
   }
   };


#2

You've got a function inside a function and you aren't calling either of them - your code doesn't do any printing. Alternatively that you've created a function that is still in memory that is being called by codecademy but that you've removed from your code.

I'm guessing you used to have code that did some printing, and that the environment (codecademy) is doing the second printing.

So my suggestion here is that you fix your code so that your function behaves like it should, and then add a line at the bottom of your code that prints out "My program has finished, any further printing isn't done by my code" or something like that. If more gets printed after that, then you know it's not your code.