If am trying to complete this challenge and does JavaScript get easier the more you use it, I’ve managed to do part of the challenge and I’m struggling with the other half can I please have some help.
Your code so far
function sum(arr, n) {
function sum(arr, n) {
if(n <= 0) {
return 0;
} else {
return sum(arr, n - 1) + arr[n - 1];
}
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
.
Challenge: Replace Loops using Recursion
Link to the challenge: