Search for a friend


#1

Hi all -

I'm not receiving an error message for my code. However, I do not think it is entirely accurate.
I'm having a hard time understanding the syntax on the "list" and "search" functions. Could someone explain?

var friends = new Object();
friends.bill = {
firstName: "Bill",
lastName: "Compton",
number: "(303) 1234567",
address:['123 West', '66th street', 'New York', 'NY', '10023'],
};
friends.steve = {
firstName: "Steve",
lastName: "Amazing",
number: "(909)8765432",
address: ['6790', '73rd street', 'New Hampshire', 'NH', '10290'],
};
var list = function (newName){
for (var anything in newName) {
console.log (anything);
}
};
var search = function(name) {
for (var key in friends) {
if (friends[key].firstName === name) {
console.log(friends[key]);
return friends[key];
}
}
};


#2

Hi in this lesson they ask you to use a for loops to print all the key and they aske you to create a function list

first writte a function list that takes a single parameter in our case friends

var list = function(friends)

and then we use the for loops like the one they put on top of the instruction so its becomes

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

I hope that I could help you.