Problem 17

Reverse an array Recursion Challenge

Given an array, return a new array with the elements in reverse order.

Function Signature

reverseArr(array)

Parameters

  • array — an array of values.

Output

Return a new array containing the same elements in reversed order.

Constraints

  • The function must use recursion.
  • The function should accept exactly one argument.

Examples

reverseArr([1, 2, 3, 4, 5]) → [5, 4, 3, 2, 1]
reverseArr([8, 6, 4, 2])    → [2, 4, 6, 8]