0

[SOLVED] clearInterval not clearing

How come my clearInterval is not clearing after the button click? need some help on this on line 30 JS.🧐 https://code.sololearn.com/WQXqc89ObFJY/?ref=app

22nd Aug 2018, 11:03 AM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar
5 Réponses
+ 5
declare it globally but assign the interval on click. var interval; function start() { interval = setInterval() }
22nd Aug 2018, 11:17 AM
Toni Isotalo
Toni Isotalo - avatar
+ 2
var interval; function autoroll() { interval = setInterval(start); } function stop() { clearInterval(interval); }
22nd Aug 2018, 11:22 AM
Toni Isotalo
Toni Isotalo - avatar
+ 1
You need to make the interval variable global and use it to clear
22nd Aug 2018, 11:07 AM
Toni Isotalo
Toni Isotalo - avatar
0
Made the clearInterval global, but still not working..
22nd Aug 2018, 11:18 AM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar
0
Thanks for the help, I appariciate it! Got it working and learned from the mistake👍
22nd Aug 2018, 11:25 AM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar