Arrays with recursion

Tell us what’s happening:

Hi Guys…

I’m not sure why, but this one is really killing me…

The concept of recursion i find a bit crazy but I’m ok with…

For me, it’s just getting the set up for the question -

“ However, notice that multiply(arr, n) == multiply(arr, n - 1) * arr[n - 1] .”

Am I being super dense to not get this??

Sorry/thanks

Your code so far


function sum(arr, n) {
// Only change code below this line

// Only change code above this line
}

Your browser information:

User Agent is: Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1.

Challenge: Replace Loops using Recursion

Link to the challenge:

Put in words,

multiply(arr, n) == multiply(arr, n - 1) * arr[n - 1]

means

{The product of the first n elements in arr} is the same as {the product of the first n - 1 elements in arr} multiplied by {the nth element in arr}

I am sure that can be clearer, but does that help somewhat?

Thanks, I’ve got it…

Not sure I could ever get that while under pressure in a real job scenario though.

Much appreciated

Help is what we’re here for. With practice I’m sure you will be able to see stuff like this easier!