Chunky Monkey

Splitting arrays into specific sized chunks using a while loop to go to the array. In the loop, I slice the array and use the count as the starting point, ending slice with count + the size. This then pushes out into the number of arrays.

by Susanna You

JavaScript

function chunkArrayInGroups(arr, size) {  
  var tempArray = [];
  var count = 0;
  
  while (count < arr.length) {
  	tempArray.push(arr.slice(count, count += size));
  }
  console.log(tempArray);
}
chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3)