Created
September 19, 2018 19:49
-
-
Save spektraldevelopment/25ca4df5de1937c3690028cd5befd9d9 to your computer and use it in GitHub Desktop.
JS: Array Chunking
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 chunk(array, size) { | |
const chunked = [] | |
let index = 0; | |
while (index < array.length) { | |
chunked.push(array.slice(index, index + size)); | |
index += size; | |
} | |
return chunked; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment