D
D
denis_213213212020-05-11 11:50:29
JavaScript
denis_21321321, 2020-05-11 11:50:29

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

1 answer(s)
H
hzzzzl, 2020-05-11
@hzzzzl

why doesn't it work, everything works
5eb912f01487b766606623.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question