function rangeOfNumbers(startNum, endNum) {
if (endNum < startNum) {
return [];
} else {
const numbers = rangeOfNumbers(startNum, endNum - 1);
numbers.push(endNum);
return numbers;
}
}
Use Recursion to Create a Range of Numbers
function rangeOfNumbers(startNum, endNum) {
return startNum <= endNum ? [startNum].concat(rangeOfNumbers(startNum + 1, endNum)) : [];
};