Skip to main content

Practice ยท 1 of 3

Narrowing Formatter

CHALLENGE
Difficulty: intermediate+25 XP

Write format(value) handling the union string | number | boolean | null | undefined: strings are trimmed then returned, numbers are formatted with exactly 2 decimals, booleans become "yes"/"no", null/undefined become "โ€”".

Back to lesson: Practice: Unions & Narrowing โ€” Practice