Created
February 19, 2018 11:05
-
-
Save dragonza/b4e86068724c91574ca38d5b6b1d9c0c to your computer and use it in GitHub Desktop.
Chunk array
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
function chunk(array, size) { | |
const chunked_arr = []; | |
let index = 0; | |
while (index < array.length) { | |
chunked_arr.push(array.slice(index, size + index)); | |
index += size; | |
} | |
return chunked_arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment