title: Chunking an array by value with odds and evens
body: <p>I'm trying to create a function that groups an array of numbers based on a length parameter. The length represents the max length of each sub-array. The code works as it is meant to for getting the sub arrays, but what I'd like to do is make it sort by odd and even. </p>
  
  <pre><code>function myFunctionA(myArr1, myVal) {
        newArr = [];
        for ( x = 0; x &lt; myArr1.length; x += myVal) {
          newArr.push(myArr1.slice(x, x + myVal));
        }
        return newArr;
      }
  Console.log(myfunction([1,2,3,4,5,6,7,8,9,10],3))
  </code></pre>
  
  <p>This returns <code>[[1,2,3],[4,5,6],[7,8,9],[10]]</code></p>
  
  <p>What I'd like to do is go through each sub array at a time until the sub arrays are the correct length and add any leftover values to a sub array/s</p>
  
  <p>This would look like </p>
  
  <pre><code>[[1,3,5][2,4,6][7,9][8,10]]
  </code></pre>
  
  <p>Since arr 0 and arr 1 are the correct length that we have stated in the console.log statement, 7 8 9 and 10 are left over. But since the can't create a full sub array and they are odds and even, they form two sub arrays with a side of 2.</p>
  
  <p>Other examples:</p>
  
  <pre><code>myfunction([1,2,3,4,5,6,7],2)
  Should return [[1,3],[2,4],[5,7],[6]]
  
  myfunction([1,2,3,4,5,6,7,8],1)
  Should return [[1][2][3][4][5][6][7][8]]
  </code></pre>