Write a function that splits an array into groups the length of size and returns them as a two-dimensional array

<script>
var new2darr = chunkArrayInGroups(["A", "B", "C", "D", "E", "F"], 4);
console.log(new2darr);  // [["A", "B", "C", "D"], ["E", "F"]]

function chunkArrayInGroups(arr, size) {
  const newArr = [];
  let i = 0;

  while (i < arr.length) {
    newArr.push(arr.slice(i, i + size));
    i += size;
  }  
  return newArr;
}
</script>
Most Helpful This Week