Search function doesn't return contact information.. but it does?


#1

Hello everyone, it's my first time here also super newbie at this programming thing.

I have this:

var friends = {};
friends.bill = {
firstNname: "Bill",
lastName: "Gates",
number: "123-123-121",
address: ['Strada soarelui', 'nr. 5', 'apt. 15']
}
friends.steve = {
firstName: "Steve",
lastName: "Jobs",
number: "323-353-232",
address: ['ul. Jezewskiego', '11a', 'm. 33']
}

var list = function(ceva) {
for (var X in ceva) {
console.log(X);
}
};

list(friends);

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

search(friends);

When i run this its telling me that "It looks like your search function doesn't return contact information for Steve." but the console looks like this:

bill
steve
{ firstName: 'Steve',
lastName: 'Jobs',
number: '323-353-232',
address: [ 'ul. Jezewskiego', '11a', 'm. 33' ] }
{"firstName":"Steve","lastName":"Jobs","number":"323-353-232","address":["ul. Jezewskiego","11a","m. 33"]}

To me, it's returning what needs to return no?

Thanks in advance for your inputs.

Alex


#2

Your function should be able to find any person, not just steve

search('Steve')