Intermediate
Overloads: Result Follows Input
measure returns the length of a string, or a number padded to three digits. As written, its result is number | string for every call, so the two typed variables below fail.
Add two overload signatures above the implementation: (value: string): number and (value: number): string. Other values (like true) must be rejected.
What Check tests
- Your code has no type errors
- The console prints
5 007 measure(true)is rejected
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Press Run to see the page.
Console
Nothing printed yet.