All challenges
Tally Words with Record
mediumutility-types100 XPProblem
Write tally(words: string[]): Record<string, number> that counts how many times each word appears in the array. Record<string, number> types the result as an object whose keys are strings and whose values are numbers. Handle first-time keys correctly — reading a missing key yields undefined.
Expected output
3
2
{"a":1}Hints
Stuck? Reveal hints one at a time.
Solution
Try solving it yourself first — revealing is always available.
Press Run in the editor — your console output is checked automatically.
No errors
Loading...
Console output appears here. Press Run or just type — the code compiles automatically.