I try to reset the game when the same form to start the game is submited. When the game start, the button change to "Stop Game", but when I try to stop the game by clicking on him (I refresh the page with location.reload() : the same thing I do to finish the game and it work), so when I try to stop the game, nothing is happening, and the console.log() is correctly executed, and I'm sure the reload() is done correctly but the game doesn't reset. Any idea ?
startForm.addEventListener('submit', function () {
if (!Game.onGame) {
Game.onGame = true
initFilters(Game)
Grid.placeRandomImages(Game)
GamePlay.run(Game)
} else {
console.log('reload')
location.reload()
}
})
---------- Solution ----------
I need to event.preventDefault() the submission of the form