Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function chunkArrayInGroups(arr, size) {
- var arr2=[];
- var j=0, i=0, numOfGroups=0;
- if(arr.length%size===0)
- numOfGroups=arr.length/size;
- else numOfGroups=arr.length/size+1;
- while((i<numOfGroups)&&(j<arr.length))
- {
- if(j%size===0)
- i++;
- arr2[i].push=(arr[j]);
- j++;
- }
- return arr2;
- }
- chunkArrayInGroups(["a", "b", "c", "d"], 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement