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

25th Aug 2019, 8:18 PM
Aziz Mandıracı
Aziz Mandıracı - avatar
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
26th Aug 2019, 3:19 AM
Gordon
Gordon - avatar
+ 2
Fuzzy Squid thx for answer.
25th Aug 2019, 8:50 PM
Aziz Mandıracı
Aziz Mandıracı - avatar
0
Well, HTML and CSS barely changes, and it's not that difficult to reset values in JS
25th Aug 2019, 8:29 PM
Airree
Airree - avatar
0
This is actually a question concerning that topic...would breaking an if statement work?
28th Aug 2019, 5:38 AM
Andrew Johnson
Andrew Johnson - avatar