Hi guys, I’m struggling to understand what’s being asked for here…
Write a recursive function,
sum(arr, n) , that returns the sum of the first
n elements of an array
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!
sum(, 0) - sum of first
0 element(s) →
sum([2, 3, 4], 1) - sum of first
1 element(s) →
sum([2, 3, 4, 5], 3) - sum of first
3 element(s) →
2 + 3 + 4 →
Thank you @sanity. Just trying to understand the problem at this stage. I appreciate your help!
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.