All academies
All challenges

Temperature Labels with Literal Types

easybasics50 XP

Problem

Define a union type TempLabel with the exact string literals "cold", "mild", and "hot". Then write classifyTemperature(celsius: number): TempLabel that returns "cold" below 10, "mild" from 10 up to (but not including) 25, and "hot" otherwise. The return type must be the union, not plain string.

Expected output

cold
mild
hot

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.