Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

using recursion to generate range of numbers

function rangeOfNumbers(startNum, endNum) {
  if (endNum < startNum) {
    return [];
  } else {
    const numbers = rangeOfNumbers(startNum, endNum - 1);
    numbers.push(endNum);
    return numbers;
  }
}
Source by forum.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #recursion #generate #range #numbers
ADD COMMENT
Topic
Name
8+1 =