From dasd, 1 Year ago, written in JavaScript.
This paste is a reply to Re: Re: dasd from dasd
- view diff
Embed
  1. function chunkArrayInGroups(arr, size) {
  2.   var newArr = [];
  3.   console.log(arr);
  4.   console.log('split by',size);
  5.  for (let i=0; i<arr.length; i+=size) {
  6.     var a = arr.slice(i, i+size);
  7.     // console.log(a)
  8.     newArr.push(a);
  9.  }
  10.  
  11.   return newArr;
  12. }
  13.  
  14. chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3)
  15.