Search for a friend


#1

var friends = {
bill: {
firstName: 'Bill',
lastName: 'Gates',
number: '(414) 444-4444',
address: ['One Microsoft Way']
},
steve: {
firstName: 'Steve',
lastName: 'Jobs',
number: '(414) 555-5555',
address: ['Infinite Valley']
}
};

var list = function (contacts) {
for (var friends in contacts) {
console.log(friends);
}
};

var search = function(name) {
for(var key in name) {
if (friends[key].firstName === name) {
console.log(friends[key]);
}
else {
return none;
}
}
};


#2

What's wrong with the code ? :slight_smile: ... i don't understand ..


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.