I'm having trouble figuring out how to generate a combination of values.
Given:
const items = ['a', 'b', 'c', 'd', 'e'];
should generate:
[
['a', 'b', 'c'],
['a', 'b', 'd'],
['a', 'b', 'e'],
['a', 'c', 'd'],
['a', 'c', 'e'],
['a', 'd', 'e'],
['b', 'c', 'd'],
['b', 'c', 'e'],
['c', 'd', 'e']
]
It generates a unique combination for all the items in the array.
Basically, the length of the array for each item is Math.round(items.length / 2)
.
Any help would be greatly appreciated.