+ 2
Why it generates infinite alerts after clicking the play button twice?
Hi, I was working on a simple game with javascript which I named "catch the murgi". Logic is quite simple, when the chicken enters inside the box, you just click on it to score! But, there are some problems and one of them is which I asked this question for. The problem is, when you press the play button twice before the game is over, it just generates alerts one after another and you can't exit from it without closing the whole app and opening it again. Please help me fix this and let me know the reason. Code link: https://code.sololearn.com/WsKL2tE2vqFW/?ref=app [NB: murgi == chicken ;)]
5 Answers
+ 3
Now i corrected it
Add Boolean, so user can't call the same function multiple times, hope you understand
https://code.sololearn.com/WRqMjVwRNmyS/?ref=app
+ 2
Add a
document.getElementById("btn).style.display = "none";
In your matha function.
And a
document.getElementById("btn).style.display = "block";
In your gameover function
+ 2
Wait that's not solved its created another problem, after catching murgi it not running š¤Ø
Edit: OK, now it's fixed
+ 1
thank you so much everyone! But I will be very happy if someone tells me what was the reason behind that?
+ 1
when one function is in progress and calling it again gives multiple values to same variable at same time, this cause some unexpected output. But I don't why it going infinite timesš¤