SHARE
TWEET

Untitled

a guest Jan 6th, 2017 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function chunkArrayInGroups(arr, size) {
  3.  
  4.   var arr2=[];
  5.   var j=0, i=0, numOfGroups=0;
  6.   if(arr.length%size===0)
  7.     numOfGroups=arr.length/size;
  8.   else numOfGroups=arr.length/size+1;
  9.   while((i<numOfGroups)&&(j<arr.length))
  10.     {
  11.       if(j%size===0)
  12.           i++;
  13.       arr2[i].push=(arr[j]);
  14.       j++;
  15.     }
  16. return arr2;
  17. }
  18.  
  19. chunkArrayInGroups(["a", "b", "c", "d"], 2);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top