2 Names getting logged


#1

So here's my code:

var friends =
{

}
friends.Bill =
{
firstName: "Bill",
lastName: "Gates",
number: "(814)-270-0604",
address: ['One Microsoft Way', 'Redmond', 'WA', '98052']
}
friends.Steve =
{
firstName: "Steve",
lastName: "Jobs",
number: "(814)-270-0604",
address: ['Cupertino', 'CA',]
}

var list = function (object)
{
for (var key in object)
{
console.log(key)
}
}

var search = function (name)
{
for (var key in friends)
{
if(friends[key].firstName === name)
{
console.log(friends[key].firstName)
console.log(friends[key].lastName)
console.log(friends[key].number)
console.log(friends[key].address)
return friends[key]
}
else
{
console.log("error")
}
}
}
list(friends)
search("Steve" && "Bill")

and for some reason I'm getting: "Bill
Steve
Bill
Gates
[ 'One Microsoft Way', 'Redmond', 'WA', '98052' ]
{"firstName":"Bill","lastName":"Gates","number":"(814)-270-0604","address":["One Microsoft Way","Redmond","WA","98052"]}" printed and I don't understand why?


#2

Never mind I found what I did wrong.