Skip to content

Instantly share code, notes, and snippets.

@SchaeStewart
Created September 18, 2018 12:34
Show Gist options
  • Save SchaeStewart/efaec7f7b823887c9afc601cd300b32f to your computer and use it in GitHub Desktop.
Save SchaeStewart/efaec7f7b823887c9afc601cd300b32f to your computer and use it in GitHub Desktop.
A simple array chunking solution
const chunkArray = (arr, chunkSize) =>
arr.reduce((prev, current, index, array) => {
if (index % chunkSize === 0) {
prev.push(array.slice(index, chunkSize + index));
}
return prev;
}, []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment