7 - this code worked, but only after i hit refresh


#1

var friends = new Object();

friends.bill = new Object();
friends.steve = new Object();

friends.bill.firstName = "Bill";
friends.bill.lastName = "Gates";
friends.bill.number = "(620) 640-0001";
friends.bill.address = ["st city st"];

friends.steve.firstName = "Steve";
friends.steve.lastName = "Jobs";
friends.steve.number = "(620) 640-0002";
friends.steve.address = ["st city st"];

var list = function(friends) {
for(var firstName in friends) {
console.log(firstName);
}
}

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


#2

@arcjumper89219,
I would suggest 1 change in your search function
like

var search = function(name){
     for (var key in friends) {
         if(friends[key].firstName === name){
            console.log(friends[key]);   //instead of console.log("Steve");
            return friends[key];
         }
     }
};