Could you explain me this block of code? (Contact List)
<p>I'm studying JavaScript on my own and I started by reading tutorials and books (like Eloquent) and articles (on Medium for example). I'm also doing some free courses, two in particular: freeCodeCamp and CodeAcademy.</p>

<p>Today I had to face a contact list exercise on CodeAcademy, and I am not sure I understood it properly.</p>

<p>After some hints, this is the final code I came up with:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var friends = {
  bill: {
    firstName: "Bill",
    lastName: "Gates",
    number: "555 555 555",
    address: ["One Miscrosoft Way", "Redmond", "WA", "98052"]
  },
  steve: {
    firstName: "Steve",
    lastName: "Jobs",
    number: "333 333 333",
    address: ["Apple's street", "Silicon Valley", "SV", "87368"]
  }
};

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

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

list(friends);
search("Steve");</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>.as-console-wrapper { max-height: 100% !important; top: 0;  }</code></pre>
</div>
</div>
</p>

<p>I understood the var friends object and the first function.
But what about the second function? Why do I need to use "name" and "key" words if they're not in the contact list. Could you explain me what the code really does?</p>

<p>Also, at the end of the exercise, CodeAcademy put this final code to do something I imagine:</p>

<pre><code>list(friends);
search("Steve");
</code></pre>

<p>What exactly is it?</p>