+ 1
javascript animation&events problem
this ball should move in the square and on click it stops & on the second click it moves till now everything is good but when you click it on the third time nothing happens on the fourth time it goes faster so how can I fix it? https://code.sololearn.com/W0xPhz40IRY3/#html
3 Answers
+ 2
Youssef Ashraf
After the first click, your code is creating extra timers but not clearing them. This is the reason the ball speed increases and does not stop.
You need to assign the setInterval() invoked at line 23 to the variable t.
+ 1
Thanks alot
+ 1
You're welcome. â