Answers for "basic javascript use recursion to create a range of numbers"

2

Basic JavaScript: Use Recursion to Create a Range of Numbers

function rangeOfNumbers(startNum, endNum) {
  if (endNum - startNum === 0) {
    return [startNum];
  } else {
    var numbers = rangeOfNumbers(startNum, endNum - 1);
    numbers.push(endNum);
    return numbers;
  }
}
Posted by: Guest on December-20-2019

Code answers related to "basic javascript use recursion to create a range of numbers"

Code answers related to "Javascript"

Browse Popular Code Answers by Language