title: How can I access the property of a nested object in Javascript?
body: <p>I need some help with accessing the property value of an object that is nested within another object.</p>
  
  <p>I have this code: </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 userStats = {
    'Jacob': {
      visits: 1
    },
    'Owen': {
      visits: 2
    },
    'James': {
      visits: 3,
    },
    'Ann': {
      visits: 4
    }
  };</code></pre>
  </div>
  </div>
  </p>
  
  <p>What I want to do is access the value of the visits.</p>
  
  <p>I have tried:</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>for(var firstName in customerData){
    console.log(firstName.visits);
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>But it is not working. It outputs 'undefined'.</p>
  
  <p>Any help is greatly appreciated.</p>