0

How to clearInterval correctly?

Can't clear the interval of the second function. https://code.sololearn.com/W1h8yXAcW7ml/?ref=app

10th Aug 2018, 6:59 AM
Akib
Akib - avatar
1 ответ
+ 10
each new call to setInterval() returns a unique identifier for that interval, which can be used later to clear that specific interval using clearInterval() because "call" function was called in intervals, your code kept on making this assignment again and again in each "call" interval: z = setInterval(cll, 500) meaning that you kept overwriting the interval IDs you were getting, therefore couldn't make clearInterval calls on them (they were lost due to being overwritten) in this implementation i solved it by only initializing z once https://code.sololearn.com/WHU29wonpnm9/?ref=app
10th Aug 2018, 7:18 AM
Burey
Burey - avatar