Your QA team wants to test the app under every combination of a handful of feature flags being switched on. Write subsets(flags), which returns every subset of flags, including the empty set (all flags off) and the full set (all on).
All flags are distinct.
subsets(['darkMode', 'beta', 'newNav']);
// [
// [],
// ['darkMode'], ['beta'], ['newNav'],
// ['darkMode', 'beta'], ['darkMode', 'newNav'], ['beta', 'newNav'],
// ['darkMode', 'beta', 'newNav'],
// ]
subsets([]); // [[]]
flags.0 ≤ flags.length ≤ 16 (2¹⁶ = 65,536 subsets).['a', 'a', 'b']) without returning duplicate subsets?Spotted a mistake or a rights concern? Report an issue