Created
September 18, 2018 12:34
-
-
Save SchaeStewart/efaec7f7b823887c9afc601cd300b32f to your computer and use it in GitHub Desktop.
A simple array chunking solution
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
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