I'm trying to run a recursive function that calculates the factorial of a number on an HTML input. I already know how to do it via iteration, I want to achieve the result recursively. But when I do it this way, I get a 'too much recursion' error. What am I missing?
HTML
<input type="text" name="factorial_input" placeholder="Enter a number">
<div class="button" onclick="calculateFactorial()">Let's see the factorial</div>
JS
function calculateFactorial(getInputValue) {
getInputValue = document.querySelector("input").value;
if (!getInputValue) {
console.log("You must enter a number");
} else if (getInputValue == 0) {
return console.log("1");
} else {
return console.log(getInputValue *= calculateFactorial(getInputValue - 1));
}
// console.log(getInputValue);
}