Beginner
Return a Pair, Typed
minMax returns the smallest and largest number. Its result is inferred as number[], so the caller's lo and hi might be undefined as far as TypeScript knows.
Give minMax a return type that is a tuple of exactly two numbers (labelled min and max). Then lo + hi type-checks, and reading a third element is an error.
What Check tests
- Your code has no type errors
loandhiare plain numbers- Reading a third element is rejected
- The console prints
1 3
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.