What is the easiest way to make grouped arrays by count in ES6?
For example I have an array with 4 items that I would like to group into groups of up to 3:
var original = [1, 2, 3, 4]
groupByCount(original, 3)
output:
[1, 2, 3]
[1, 3, 4]
[1, 2, 4]
[2, 3, 4]
[1]
[2]
[3]
[4]
[1, 2]
[2, 3]
[1, 4]
[2, 4]
[3, 4]
[1, 3]
Order insensitive.