This is kind of confusing so I will just demonstrate. I would like to create a function that takes an array like this:
[1, 2, 3, 4, 5, 6, 7]
...and returns an array of arrays like this:
[[1, 5], [2, 6], [3, 7], [4]]
assuming that the user wanted 4 groups. Notice that the elements are added to each group before 5th element is added back to the first.
Is there a simple way to do this? My project is using webpack, so I am open to ES6+ or even lodash. Thanks!
[[1, 5, 9], [2, 6, 10], [3, 7], [4, 8]]