Search for a friend: My code logs Steve's information multiple times


#1

The codes doesn't return any error, but it logs steve's information multiple times. Pls what is wrong with the code?

var billAdr = ['vgc','lekki','lasgidi'];
var steveAdr = ['house 50','lasgidi'];

var friends = new Object();

friends.bill = new Object();
friends.bill.firstName = "Bill";
friends.bill.lastName = "Hamde";
friends.bill.number ="086778944";
friends.bill.address = billAdr;

friends.steve = new Object();
friends.steve.firstName = "Steve";
friends.steve.lastName = "wurk";
friends.steve.number = "0864636389";
friends.steve.address = steveAdr;

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

#2

@skillz06,

++++ why second display of last Item
+++++++++++++++++++++++++++++
It is the Javascript interpreter which is running in this course-environment,
it display's the last non-displayed action...

You will also encounter this, when you are doing a return-statement
as last action...
You could counter this by using a
console.log( " " ); as last statement....

In some sections of this course, the course-checker Display's data
this you could then identify by placing to EXTRA code-line's:
console.log( "== My End ==" );
console.log( "== All that is displayed now, is the course-checker ==" );