7. Search for a friend---I have passed it, but need help on understanding


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

https://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/7?curriculum_id=506324b3a7dffd00020bf661#<In what way does your code behave incorrectly? Include ALL error messages.>

```

Can someone please give me descriptive information on how this code works, starting at the first function?

var friends = {
steve: {
firstName: “Steve”,
lastName: “Jobs”,
number: “111-111-111”,
address: [“some address somewhere”]
},
bill: {
firstName: “Bill”,
lastName: “Gates”,
number: “222-222-2222”,
address: [“another address somewhere”]
}
};
var list = function (friends) {
for(var firstName in friends) {
friends[firstName]
console.log(firstName);
}
};
var search = function (name) {
for (var firstName in friends) {
if (friends[firstName].firstName === name) {
console.log(friends[firstName]);
return friends[firstName];
}

}

};

<do not remove the three backticks above>

#2

@kenneth1026,

+++ 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