Assume I have this array:
const input = [“a”, “b”, “c”, “d”];
I want to create this output:
[
[“a”],
[“a”, “b”],
[“a”, “c”],
[“a”, “d”],
[“a”, “b”, “c”],
[“a”, “b”, “d”],
[“a”, “c”, “d”],
[“a”, “b”, “c”, “d”],
[“b”],
[“b”, “c”],
[“b”, “d”],
[“b”, “c”, “d”],
[“c”],
[“c”, “d”],
[“d”]
]
I don’t care about the order, or the length of the combos, just need all the various ways to uniquely combine the items in the array.
What is the best way to do this in JavaScript? I suspect there’s a beautiful recursive solution, but iterative would work too.
Also, what is the correct technical term for this?