Search For A Friend code


#1


I got the code to work, but it's showing all of Steve's info twice, then once for Bill, then only Steve's address. Did I omit something to cause this? Or does Steve not like that his last name is Loser?

Joking aside, I really can't figure that out.

Thanks!


var friends = new Object();
    friends.bill = new Object();
        friends.bill.firstName = "Bill";
        friends.bill.lastName = "Gates";
        friends.bill.number = "1234567";
        friends.bill.address = ['One Microsoft Way', 'Redmond', 'WA', '98052'];
    friends.steve = new Object();
        friends.steve.firstName = "Steve";
        friends.steve.lastName = "Loser";
        friends.steve.number = "8901234";
        friends.steve.address = ['One Apple Drive', 'Crap', 'Crappy', '34560'];
//---
var list = function(friends){
    for (var firstName in friends){
        console.log(firstName);
    };
};
var search = function(name){
    for (var firstName in friends){
       if (friends.bill.firstName === name){
           console.log(friends.bill);
           return(friends.bill);
      }else{
            console.log(friends.steve);
            return(friends.steve);
           };
       };
};


#2

@jdubsee

This is because of codeacademy, sometimes they print something else in the command that it's not supposed to print according to the code.

Lol maybe you should try Steve Jobs :joy: