Problem 9

Reverse String Recursion Challenge

Given a string, return a new string with its characters in reverse order.

Function Signature

reverse(string)

Parameters

  • string — a string of characters.

Output

Return a new string that is the reverse of the input.

Constraints

  • The function must use recursion.
  • Do not use Array.prototype.reverse.
  • The function should accept exactly one argument.

Examples

reverse('recursion')                    → 'noisrucer'
reverse('All my base are belong to you.') → '.uoy ot gnoleb era esab ym llA'
reverse('traf')                         → 'fart'