Guest User

Untitled

a guest
Feb 24th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. var array_chunk = function(array, size) {
  2.  
  3. var output = [],
  4. i = 0,
  5. n = 0;
  6.  
  7. for(item in array) {
  8.  
  9. if(i >= size) {
  10. i = 0;
  11. n++;
  12. }
  13.  
  14. if(!output[n] || output[n] == 'undefined') {
  15. output[n] = [];
  16. }
  17.  
  18. output[n][i] = array[item];
  19.  
  20. i++;
  21.  
  22. }
  23.  
  24. return output;
  25.  
  26. };
Add Comment
Please, Sign In to add comment