

Sensor Labels
Weather balloons report a temperature in degrees, or null when a sensor is offline. Write labelReadings(readings: (number | null)[]): string[] that turns each reading into a label:
nullbecomes"offline"- below 0 becomes
"freezing" - 0 up to and including 25 becomes
"mild" - above 25 becomes
"hot"
Check for null first. After that check, TypeScript knows the reading is a number.
Examples
labelReadings([null, -4, 18, 31])
→ ["offline", "freezing", "mild", "hot"]
labelReadings([0, 25, 25.5])
→ ["mild", "mild", "hot"]
solution.ts
TYPESCRIPT
Saved as you type
Tests
0 of 4 passing- •one of eachlabelReadings([null, -4, 18, 31])expected ["offline", "freezing", "mild", "hot"]
- •edgeslabelReadings([0, 25, 25.5])expected ["mild", "mild", "hot"]
- •all quietlabelReadings([null, null])expected ["offline", "offline"]
- •no readingslabelReadings([])expected []
On the line
+40 XP
Pass all 4 tests to claim it.
