Skip to content

Instantly share code, notes, and snippets.

@onestepcreative
Created March 9, 2014 00:46
Show Gist options
  • Select an option

  • Save onestepcreative/9441335 to your computer and use it in GitHub Desktop.

Select an option

Save onestepcreative/9441335 to your computer and use it in GitHub Desktop.
helper function to quickly break up array into smaller equal size arrays
function chunkitup(arr, chunks) {
var len = arr.length;
var out = [];
var i = 0;
while (i < len) {
var chunkSize = Math.ceil((len - i) / chunks--);
out.push(arr.slice(i, i + chunkSize));
i += chunkSize;
}
return out;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment