Basic JavaScript - Replace Loops using Recursion

Tell us what’s happening:
Hi all,

I got up to recursions and loops and I think i am missing some math knowledge here to fully grasp the concept.
I’d be grateful for any recommendations on resources (free would be even better) that I can learn the necessary math/algorithm to better understand concepts in js?

Your code so far

function sum(arr, n) {
  if ( n <= 0){
    return 0;
    return sum(arr, n-1) + arr[n-1];
  // Only change code below this line

  // Only change code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic JavaScript - Replace Loops using Recursion

Link to the challenge:

You dont need to know a lot of math to understand recursion if you can add subtract and multiply you should be able to grasp it. But recursion is a very confusing topic if you haven’t seen it before. Just search the internet and read up more on recursion. If you dont understand it right away you can almost allways use regular loops in your code to accomplish the same thing without using recursion.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.