Recursion clarification request

Hi guys, I’m struggling to understand what’s being asked for here…

Recursive challenge

Write a recursive function, sum(arr, n) , that returns the sum of the first n elements of an array arr .

I know what the sum of numbers means.
I know that ‘n’ is the second parameter/argument.

When I look at the rules below…

Challenge guide picture


I’m not sure how the bottom two values have been arrived at. Can anyone help clarify this please.

Thanks for your help!

Challenge link

sum([1], 0) - sum of first 0 element(s) → 0
sum([2, 3, 4], 1) - sum of first 1 element(s) → 2
sum([2, 3, 4, 5], 3) - sum of first 3 element(s) → 2 + 3 + 49


Thank you @sanity. Just trying to understand the problem at this stage. I appreciate your help!

1 Like