Last active
December 26, 2017 19:12
-
-
Save AviTapp/2de37814587fe6d61eb39648912daae7 to your computer and use it in GitHub Desktop.
Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function chunkArrayInGroups(r, n) { | |
var u = [], | |
c = 0, | |
e = n, | |
h = []; | |
for (i = 0; i < r.length;) u = r.slice(c, e), h.push(u), c += n, e += n, i += n; | |
return h | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment