Created
September 18, 2015 14:23
-
-
Save ceaksan/192f227b741622dc0a3b to your computer and use it in GitHub Desktop.
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 chunk(arr, size) { | |
var temp = [], result = []; | |
for (var a = 0; a < arr.length; a++) { | |
if (a % size !== size - 1) temp.push(arr[a]); | |
else { temp.push(arr[a]); result.push(temp); temp = []; } | |
} | |
if (temp.length !== 0) result.push(temp); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment