Answers for "recursion javascript Get the integers in range (x, y)."

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 "recursion javascript Get the integers in range (x, y)."

Code answers related to "Javascript"

Browse Popular Code Answers by Language