title: Push chunks of an array into another array in JavaScript
body: <p>I have an array of map points that contain speeds and I want to create a new array of every 25 points and push them into another array called chunks. So this is what I am doing:</p>
  
  <pre><code>var chunks = []; // the array of chunks
  var tempArray = []; //used for storing current chunk
  var currentLoop = 0; //used for checking how many items have been taken
  for (var i = 0; i &lt; gon.map_points.length; i++) {
      if (currentLoop == 26) { // if the current items stored is above 25
          chunks.push(tempArray); // push the chunk
          currentLoop = 0; // reset the count
          tempArray = []; // reset the chunk
      }
      tempArray.push(gon.map_points[i].speed); // add item into chunk
      currentLoop++; // increase count
  }
  </code></pre>
  
  <p>So this works fine unless the array of map points isn't a perfect number of points (e.g. it might be 117), so then I won't get the last 17 points added to my chunks array.</p>
  
  <p>Is there a way to chunk up the array into 25 points regardless of the total items?</p>