title: Loop Over Array in Javascript
body: <p>I'm using Google Chrome's Console window to try and figure out why I'm not able to loop over an array in javascript.</p>
  
  <p>I have a javascript object called <code>moveResult</code> that looks like this:  </p>
  
  <p><img src="https://i.stack.imgur.com/VxCKD.jpg" alt="enter image description here"></p>
  
  <p>I'm trying to loop over the <code>MoveParts</code> in javascript like this:</p>
  
  <pre><code>for (var movePart in moveResult.MoveParts) {
      console.log(movePart.From);
  };
  </code></pre>
  
  <p>I always get <code>undefined</code> instead of the actual value.  However, If I try to access the first item explicitly I get what I want, like this:</p>
  
  <pre><code>console.log(moveResult.MoveParts[0].From);
  </code></pre>
  
  <p>The result of this is <code>"b1"</code>.</p>
  
  <p><strong>Why isn't my loop working?</strong></p>
  
  <p>I've also tried a foreach:</p>
  
  <pre><code>moveResult.MoveParts.foreach(function (movePart) {
      console.log(movePart.From);
  };
  </code></pre>