title: Accessing a property of an object that is nested inside another object in Javascript
body: <p>I'm trying to access a property of an object that is nested inside an object. Am I approaching it the wrong way, is my syntax wrong, or both? I had more 'contacts objects inside, but eliminated them to shrink this post.</p>
  
  <pre><code>var friends = {
      steve:{
          firstName: "Rob",
          lastName: "Petterson",
          number: "100",
          address: ['Thor Drive','Mere','NY','11230']
      }
  };
  
  //test notation this works:
  //alert(friends.steve.firstName);
  
  function search(name){
      for (var x in friends){
          if(x === name){
                 /*alert the firstName of the Person Object inside the friends object
                 I thought this alert(friends.x.firstName);
                 how do I access an object inside of an object?*/
          }
      }
  }  
  
  search('steve');
  </code></pre>