#8 Victory. My code says it's correct, but I get an undefined outcome when I run it


#1

var friends = new Object ();

friends.bill = new Object ();
friends.bill.firstName = "Bill";
friends.bill.lastName = "Gates";
friends.bill.number = "(555) 555-5555";
friends.bill.address = ['One Microsoft Way' , 'Corning' , 'New York'];

friends.steve = new Object ();
friends.steve.firstName = "Steve";
friends.steve.lastName = "Jobs";
friends.steve.number = "(666) 666-6666";
friends.steve.address = ['12 Apple Court' , 'Alabaster' , 'New Hampshire'];

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

var name = prompt ("Type bill");

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

list(friends);
console.log(search(friends)); //for testing purposes

Not sure what is going on I'm at the very end of the contact list set.


#2

The foible. We would never ask our function to search for its entire database as a single object.

console.log(search("Bill"));