7. search for a friend


#1

I dont get it.
code:

var friends = {};

friends.bill = {
firstName:"Bill",
lastName:"Gates",
number:"(206) 555-5556",
address:['One Micro Town', 'Red street']
};
friends.steve = {
firstName:"Steve",
lastName:"Jobs",
number:"(206) 555-5557",
address:['Pillow Town', 'Pink Street']
};
var list = function(friends){
for(bill in friends){
console.log(bill);
}
}
var search = function(name){
for(steve in friends){
if(friends[steve].firstname === name){
console.log(friends[steve]);
return friends[steve];
}
}
}
search("Steve");


#2

@jan.s,

+++ friends list and search and for-in explained.
Look here for an explanation
object
function
for-in-loop
list-function
search-function
http://www.codecademy.com/forum_questions/545275fd8c1ccc8e3e000a23#comment-5457b12c9c4e9d87cb00003f