Skip to content

Instantly share code, notes, and snippets.

Niklas Fondberg fondberg

View GitHub Profile
View Split array into N number of arrays
const splitArray = (inArray, buckets) => {
return inArray.reduce((retArr, value, index) => {
const bucket = index % buckets;
if (!retArr[bucket]) {
retArr[bucket] = [];
}
retArr[bucket].push(value)
return retArr
}, [[]]);
}
You can’t perform that action at this time.