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 Answers
+ 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