Monday, 15 October 2018

How to pass variable from setInterval to the next interval without global variable?

I have quite a few countdown timers and I don't want to make a global variable for each and every one as they are programmatically generated. How can I pass a variable from one instance of a setInterval to the next instance?This currently only logs zeros:var timer = setInterval((count)=>{if(count === undefined){count = 0} else if(count===10){clearInterval(timer)}console.log(count)count++},1000)

Submitted October 15, 2018 at 02:49PM by CSS_Programmer

No comments:

Post a Comment