first post so I'm trying to follow the rules here best I can. I'm trying to write a simple function that uses recursion to return the sum of all numbers between 1 and num. I've seen the solution to this, and I get how it works, but I don't get why THIS solution doesn't work. Any feedback is appreciated.
const sumNums = (num) => {
let total = 0;
if(num >= 1) {
total += num;
sumNums(num-1);
}
return total;
}
console.log(sumNums(5)); // <-- returns 5