'setTimeout Javascript 'Timer'

let doit = (from, to) => {
  let a = setTimeout(doit, 500, ++from);
  console.table(from);
  if (from === to) {
    clearTimeout(a)
  }
};

 doit(6, 13);
Write a printNumbers(from, to) function that prints a number every second, starting from from and ending with to . Can you describe me why this timer is not stopping? Can you answer with comments please.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source