Skip to content

Instantly share code, notes, and snippets.

@jkantr
Created June 8, 2017 16:36
Show Gist options
  • Save jkantr/61d07d1c4ff45ff4737b63d3397bdaab to your computer and use it in GitHub Desktop.
Save jkantr/61d07d1c4ff45ff4737b63d3397bdaab to your computer and use it in GitHub Desktop.
Fold large array into an array of arrays of N length
const foldArr = (arr, groupSize) => arr.reduce((a, b, i, g) => !(i % groupSize) ? a.concat([g.slice(i, i + groupSize)]) : a, []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment