title: Trying to split array into specified amount of subarrays in javascript
body: <p>I'm writing a function that takes an array and a number parameter and returns the number amount of arrays split from the given array. So the call chunkArrayInGroups(["a", "b", "c", "d"], 2); should return [a,b] [c,d]. My code is returning [a,c] [b,d]. It should be an easy solution, but I still can't figure out. </p>
  
  <pre><code>function chunkArrayInGroups(arr, size) {
  // Break it up.
  
  var newarr=[];
  var amount=0;
  if(arr.length%2===0)
  {
    amount=arr.length/size;
  }
  else
  amount=(arr.length/size)+1;
  console.log(amount);
  for(i=0;i&lt;amount;i++)
  {
    newarr[i]=[];
  }
  console.log(newarr);
  for(z=0;z&lt;arr.length;z=z+size)
  {
  
    for(x=0;x&lt;size;x++)
      {
        newarr[x].push(arr[z+x]);
  
      }
  
  
     }
    console.log(newarr);
     }
  
    chunkArrayInGroups(["a", "b", "c", "d"], 2);
  </code></pre>
  
  <p>Also, if you see bad syntax please correct me, I'm used to writing Java. Thank you!</p>