+ 2
How do I restart/reset the code in Javascript?
I am making a game .In that game there are 3 lives totally.I I want to restart/reset the whole code when lives are 0.(using HTML/CSS/JS for game)
6 Antworten
+ 4
declare the variables such as score and live at global scope (outside any function) without initializing.
define a function named init to initialize these global variables.
at game end, prompt gameover modal box and display a button for restart.
the restart button is listening to click event, with init as the callback.
https://code.sololearn.com/WrZat1vLX669/?ref=app
+ 2
Fuzzy Squid thx for answer.
0
Well, HTML and CSS barely changes, and it's not that difficult to reset values in JS
0
This is actually a question concerning that topic...would breaking an if statement work?