Basic JavaScript: Use Recursion to Create a Range of Numbers
snippet in javascript

Basic JavaScript: Use Recursion to Create a Range of Numbers

user3815

function rangeOfNumbers(startNum, endNum) {
  if (endNum - startNum === 0) {
    return [startNum];
  } else {
    var numbers = rangeOfNumbers(startNum, endNum - 1);
    numbers.push(endNum);
    return numbers;
  }
}