Created
October 9, 2019 15:30
-
-
Save MartinMuzatko/b8150b99cebb31d8b222ac88a69999f7 to your computer and use it in GitHub Desktop.
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
const chunk = (items, chunkSize) => | |
[...Array(Math.round(items.length / chunkSize))] | |
.map((_, index) => | |
items.slice( | |
index * chunkSize, | |
index * chunkSize + chunkSize)) | |
// chunk([1,2,3,4,5], 2) | |
// [[1,2], [3,4], [5]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment