Last active
September 17, 2020 12:34
-
-
Save naramdash/2c607b95d883ee9649af25d2218fc406 to your computer and use it in GitHub Desktop.
split array to small array with maxLength
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
function sliceToSmallArray(acc, arr, maxLength) { | |
if (arr.length === 0) return acc | |
if (arr.length <= maxLength) return [...acc, arr] | |
return sliceToSmallArray([...acc, arr.slice(0, maxLength)], arr.slice(maxLength), maxLength) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment