(12) Unexpected Console Output (Two "Steeves," One "Bill," No "Dani") but CODE IS GOOD


#1

Console Output
bill
steve
dani
{ firstName: 'Steve',
lastName: 'da Beev',
number: 'zero',
address: [ '1010 to Nowhere St', 'Montreal', 'PQ', 'H0H 0H0' ] }
{ firstName: 'Steve',
lastName: 'da Beev',
number: 'zero',
address: [ '1010 to Nowhere St', 'Montreal', 'PQ', 'H0H 0H0' ] }
{ firstName: 'Bill',
lastName: 'Bob',
number: '(111) 222 3344',
address: [ '123 Fake St', 'Montreal', 'PQ', 'H0H 0H0' ] }

This is enabling me to move forward to the next level, but doesn't seem to be a logical output, nor does it search "dani."
I've played around with the search function and added/removed console.logs but I'm not getting a neat return.

What did you print?
Anybody able to generate only their searched name's info? Otherwise, what's the point of this?

My Code:
var friends = {
bill: {
firstName: "Bill",
lastName: "Bob",
number: "(111) 222 3344",
address: ['123 Fake St', 'Montreal', 'PQ', 'H0H 0H0']
},
steve: {
firstName: "Steve",
lastName: "da Beev",
number: "zero",
address: ['1010 to Nowhere St', 'Montreal', 'PQ', 'H0H 0H0']
},
dani: {
firstName: "Dani",
lastName: "Heartthrob",
number: "1",
address: ['Cat House', 'Montreal', 'PQ', 'H0H 0H0']
}
};
var list = function (friends) {
for (var ahh in friends) {
console.log(ahh);
}
}
var search = function (name) {
for (var ahh in friends) {
if (friends[ahh].firstName === name) {
console.log(friends[ahh]);
return friends[ahh];
}
}
};
list (friends);
search ("dani");
console.log("");


#2

@heynah,
Try using

search ("Dani");

#3

Yes, so simple!
Thank you @leonhard_wettengmx_n