I honestly did not see that because I was on mobile and code blocks on Medium are terrible.
At any rate, returning the clearTimeout in this manner actually does nothing at all. clearTimeout() is used to cancel a timeout before it executes its callback. The way he does this, it instead returns a function that does this without invoking it. If he wants to invoke clearTimeout(), he needs to instead return a self-invoked function : return (() => { clearTimeout(timer) } )();
Doing that however would not increment the count at all. clearInterval() on the other hand is what cancels a looping timer. clearTimeout() is to setTimeout() as clearInterval is to setInterval().