Created
April 16, 2020 08:17
-
-
Save EastSun5566/326aee7b4d30eaea3c66ae0c211019d7 to your computer and use it in GitHub Desktop.
Creates an array of elements split into groups the length of size.
This file contains hidden or 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 chunk = (input, size) => input.reduce((arr, item, index) => index % size === 0 | |
? [...arr, [item]] | |
: [...arr.slice(0, -1), [...arr.slice(-1)[0], item]], []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment