function rangeOfNumbers(startNum, endNum) {
let numArr = [];
if (startNum === endNum ) {
numArr.push(endNum)
return numArr;
} else {
numArr.push(endNum)
return rangeOfNumbers(startNum, endNum-1)
}
};
console.log(rangeOfNumbers(6,9))
function rangeOfNumbers(startNum, endNum) {
let numArr = [];
if (startNum === endNum ) {
numArr.push(endNum)
return numArr;
} else {
numArr.push(startNum)
return [...numArr, ...rangeOfNumbers(startNum + 1, endNum)]
}
};
console.log(rangeOfNumbers(6,9))
function rangeOfNumbers(startNum, endNum, accumulator = []) {
accumulator.unshift(endNum)
if (startNum === endNum ) {
return accumulator;
} else {
return rangeOfNumbers(startNum, endNum-1, accumulator)
}
};
let numArr = [];
function rangeOfNumbers(startNum, endNum) {
if (startNum === endNum ) {
numArr.push(endNum)
return numArr;
} else {
numArr.push(endNum)
return rangeOfNumbers(startNum, endNum-1)
}
};