Skip to content

Instantly share code, notes, and snippets.

@kevinmarx
Last active December 19, 2015 18:18
Show Gist options
  • Save kevinmarx/5997177 to your computer and use it in GitHub Desktop.
Save kevinmarx/5997177 to your computer and use it in GitHub Desktop.
Method for chunking arrays into a 2 dimensional array.
function(array, chunk) {
return [].concat.apply([],
array.map(function(elem, i) {
return i % chunk ? [] : [array.slice(i, i + chunk)]
})
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment