All challenges
Narrow with typeof
easytype-guards50 XPProblem
Write describeValue(value: string | number | boolean): string. For strings, return "string of length N". For numbers, return "number doubled to N". For booleans, return "boolean: true" or "boolean: false". Use typeof checks so TypeScript narrows the union in each branch.
Expected output
string of length 5
number doubled to 42
boolean: trueHints
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.