I try to understand how it works on Recursion lesson and I try to use the code on VS code but I don’t understand why the result is NaN. Can somebody help me to explain more about recursion?
function multiply(arr, n) {
if (n <= 0) {
return 1;
} else {
return multiply(arr, n - 1) * arr[n - 1];
}
}
var re = multiply(1,10);
console.log(re);