Skip to content

Instantly share code, notes, and snippets.

@FrozenIce0617
Created January 11, 2021 16:50
Show Gist options
  • Save FrozenIce0617/cf5be7d399c667b5a735ef19368745a5 to your computer and use it in GitHub Desktop.
Save FrozenIce0617/cf5be7d399c667b5a735ef19368745a5 to your computer and use it in GitHub Desktop.
const groupArrayElements = ((arr, divideCnt) => {
const res = [];
const arraySize = arr.length;
const increment = Math.ceil(arraySize / divideCnt);
for (let i = 0; i < arraySize; i += increment) {
res.push(arr.slice(i, i + increment));
}
return res;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment