0 of 6 problems solved0%
6 of 6

Init Counts from Tuple

A readonly tuple of keys plus typeof KEYS[number] yields a union of those keys. Use it to build a Record<Key, number> and initialize counts. This ties a runtime list directly to a static type.

const KEYS = ["todo", "done"] as const;
type Key = (typeof KEYS)[number]; // 'todo' | 'done'

Initialize all counts to zero.

Your Task

Create a count map from a const tuple of statuses.

  • Declare const STATUSES = ['todo', 'doing', 'done'] as const.
  • Define type Status = typeof STATUSES[number].
  • Implement function initCounts(): Record<Status, number> that returns an object with those keys set to 0.
  • Do not hardcode unrelated keys; derive them from STATUSES.