Skip to content

Instantly share code, notes, and snippets.

@ceaksan
Created September 18, 2015 14:23
Show Gist options
  • Save ceaksan/192f227b741622dc0a3b to your computer and use it in GitHub Desktop.
Save ceaksan/192f227b741622dc0a3b to your computer and use it in GitHub Desktop.
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