title: Correctly Breaking from Nested For Loops in Javascript
body: <p>Having some trouble with nested for loops. I have one big array called pointArray, and then a few smaller colorArrays made up of values from the pointArray. I want to 
  1) figure out the index of player 1's position in the pointArray 
  2) count UP from that index in the point array until a match is found in the colorArray
  3) return the matching index in the color array (I called that variable "dest")
  4) move the player to that destination using tweenJS.</p>
  
  <p>Step 1 is working correctly, and step 4 is working to an extent. Instead of moving a player to the next destination in the colorArray, it keeps moving the player to colorArray[0], due to the fact that variable dest = 0, which means that my for loop is not storing the value of dest correctly. I suspect that my issue has to do with the scope of my counter variables and an error in the nested for loop. </p>
  
  <pre><code>var pointArray = [{x:70, y:500},
      {x:120, y:500},...];
  var currentPos, dest;
  
  function findPoint(color) {
  
  for (var i=0; i &lt; pointArray.length; i++) {
      if (player1.x === pointArray[i].x &amp;&amp; player1.y === pointArray[i].y) {
          currentPos = i;
          break;
      }
  }
  var m = currentPos + 1;    
  for(m;m&lt;pointArray.length; m++) {
      for(var n=0;n&lt;color.length; n++){
          if (color[n].x === pointArray[m].x &amp;&amp; color[n].y === pointArray[m].y) {
              dest = n;
              break;   
          }
          break;
      }
  }
  
  createjs.Tween.get(player1)
      .wait(500)
      .to({x:color[dest].x,y:color[dest].y}, 1000, createjs.Ease.quadIn);
  }
  </code></pre>
  
  <p>Update: code fixed using "break checks"</p>
  
  <pre><code>var breakCheck1;
  for(m;m&lt;pointArray.length; m++) {
      for(var n=0;n&lt;color.length; n++){
          if (color[n].x === pointArray[m].x &amp;&amp; color[n].y === pointArray[m].y) {
              dest = n;
              breakCheck1= true;
              break;
          } else {console.log("This loop ran but didn't catch");}
      if (breakCheck1) {break;}
      }
  if (breakCheck1) {break;}
  }
  </code></pre>