Check Feature Flags by Known Name
Write the code, see it run, pass the checks.
The problem
- easy
- Code
Feature flags arrive as an object mapping each flag's name to true or false. Write isEnabled(flags, key), which says whether that flag is switched on (anything but true counts as off), and enabledFlags(flags), which lists the names of the flags that are on, in the object's order. Type them so key must be one of the configured flags, making a misspelt flag name a type error rather than a silent false, and so enabledFlags returns those names, not just strings.
Your code must pass
- Says whether a flag is on
- Lists the flags that are on, in order
- Has no type errors
- Rejects an unknown flag name
- Lists flags by their names