A product grid has a row of filter chips, one per tag in tags. A shopper can switch on any mix of chips, including none.
Write allFilterSelections(tags) that returns every possible selection as an array of the tags that are on.
The selections may be in any order, and the tags inside a selection may be in any order. Every selection must appear exactly once.
Input: tags = ["sale","new"] Output: [[],["sale"],["new"],["sale","new"]]
Each chip is on or off, so 2 chips give 2 × 2 = 4 selections, including none.
Input: tags = ["red"] Output: [[],["red"]]
One chip: off or on.
0 <= tags.length <= 10Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #292 Every Filter Chip Selection. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.