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


#1


https://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/7?curriculum_id=506324b3a7dffd00020bf661#


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];
      }
      
  }
    
    
};


#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