7: correct search function prints additional names


#1

Hi, so this is supposed to be right, and I'm getting the "way to go" BUT I don't understand why my code and "bill" search function gives me the Steve Jobs Info twice before the Bill info I requested. Any ideas?
This is the code:
var friends = {
bill : {
firstName : 'Bill',
lastName : 'Gates',
number : 1234,
address : ['One Microsoft Way','California','USA']
},
steve : {
firstName : 'Steve',
lastName : 'Jobs',
number : 5678,
address : ['One Apple Way','California','USA']
},
};

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(friends[key]);
return friends[key];
}
}

};

search("bill");

and this is the output:
{ firstName: 'Steve',
lastName: 'Jobs',
number: 5678,
address: [ 'One Apple Way', 'California', 'USA' ] }
{ firstName: 'Steve',
lastName: 'Jobs',
number: 5678,
address: [ 'One Apple Way', 'California', 'USA' ] }
{ firstName: 'Bill',
lastName: 'Gates',
number: 1234,
address: [ 'One Microsoft Way', 'California', 'USA' ] }


#2

Are you getting any errior messages?


#3

no nothing. ill try on esprima


#4

nothing there either.


#5

The SCT is probably sending it's own search of Bill and Steve.