I'm having a problem trying to write a body for a function that recursively reverse an array, but only has one parameter.
function ReverseArray(arr) {
var i = 0;
var j = arr.length - 1;
if (i < j) {
var temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
return ReverseArray(arr);
}
return arr;
}
I realize this won't work because the variables will be re-initialized when the function calls itself.
I'm just looking for some ideas at this point, because i'm stuck.