-
-
Save jkantr/61d07d1c4ff45ff4737b63d3397bdaab to your computer and use it in GitHub Desktop.
Fold large array into an array of arrays of N length
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 foldArr = (arr, groupSize) => arr.reduce((a, b, i, g) => !(i % groupSize) ? a.concat([g.slice(i, i + groupSize)]) : a, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment