All academies
All challenges

Function Overloads: Reverse

mediumfunctions100 XP

Problem

Write a reverse function with two overload signatures: reverse(input: string): string and reverse(input: number[]): number[]. Callers passing a string must get a string back, and callers passing a number array must get a number array back — without any casts at the call site. Implement both behaviors in a single implementation signature.

Expected output

tpircsepyt
[3,2,1]

Hints

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.