Answers for "countdown javascript recursivity"

3

Basic JavaScript: Use Recursion to Create a Countdown

function countdown(n){
  if (n < 1) {
    return [];
  } else {
    const arr = countdown(n - 1);
    arr.unshift(n);
    return arr;
  }
}
console.log(countdown(5)); // [5, 4, 3, 2, 1]
Posted by: Guest on December-20-2019
0

countdown recursion javascript

const recursiveRangeSum = (num, total = 0) => {  if (num <= 0) {    return total;  }  return recursiveRangeSum(num - 1, total + num);};
Posted by: Guest on March-22-2021

Code answers related to "countdown javascript recursivity"

Code answers related to "Javascript"

Browse Popular Code Answers by Language