Answer the question
In order to leave comments, you need to log in
Why doesn't recursive function work with setInterval?
When pressed, the function does not fire
Or can a recursive function be combined with setInterval ? It works without setInterval .
let button = document.querySelector('.button');
let pow = (n) => {
if(n == 1) {
return n;
}
else {
return n * pow(n - 1)
}
}
button.onclick = () => {
console.log(setInterval(pow, 1000, 5));
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question