Last active
April 19, 2019 05:22
-
-
Save dan-maximov/452c9dd027a8c7b7310f0ed6863859cb to your computer and use it in GitHub Desktop.
chunk array
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 getChunks = (arr, size) => { | |
const sets = []; | |
const chunks = arr.length / size; | |
let i = 0; | |
while (i < chunks) { | |
sets[i] = arr.splice(0, size); | |
i++; | |
} | |
return sets; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment