Practice ยท 1 of 3
Narrowing Formatter
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 "โ".
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Unions & Narrowing โ Practice