Hi everyone. I am doing the ‘Create a Range Numbers’ with recursion section, and when I test my code the console says this ‘RangeError: Maximum call stack size exceeded’, and I don’t know why. This is my code:
function rangeOfNumbers(startNum, endNum) {
if (endNum < startNum) {
return [];
} else {
const countArray = rangeOfNumbers(startNum, endNum - 1);
countArray.push(endNum);
console.log(countArray); // This line is only to see what happens with the array.
return countArray;
}
};
rangeOfNumbers(10);