0 of 6 problems solved0%
3 of 6

Settings with Index

Sometimes you don’t know property names in advance. An index signature says: any string key is allowed, and its value has one of a few types. This is useful for settings, flags, or small dictionaries.

interface Flags {
  [key: string]: boolean;
}

You will count how many settings are turned on.

Your Task

Count enabled flags in a settings object.

  • Define interface Settings { [key: string]: string | number | boolean }.
  • Implement countEnabled(s: Settings): number that returns how many values are exactly true.
  • Return 0 when the object has no keys.
  • Do not mutate the input.