(JS bug) Unable to clear Interval as I want in my game Plz help me in my code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

(JS bug) Unable to clear Interval as I want in my game Plz help me in my code

In JS line no. 89 https://code.sololearn.com/W3KVNDOGY95I/?ref=app

4th Apr 2020, 8:21 AM
Abhay
Abhay - avatar
2 Answers
0
It seems that the correct gameplay is : Whenever ANY direction button us clicked, clearInterval will clear the current interval, and then a new interval will apply. To do this, use one global variable to store the interval, and add clearInterval at beginning of every event listener. clearInterval Tutorial: https://code.sololearn.com/WgW0wqXU1LXl/?ref=app fix for you: https://code.sololearn.com/WgaoqB2wJCzN/?ref=app
4th Apr 2020, 8:54 AM
Gordon
Gordon - avatar
- 1
sololearn code compiler is not that good try w3schools js compiler instead. u will get ur problem detect more easily.
5th Apr 2020, 4:23 AM
Sandeep Yadav
Sandeep Yadav - avatar