Old code:
restart("👎 Game Over. Try again!");
playerLives = 10;
playerLivesCount.textContent = playerLives;
setTimeout(() => window.alert(text), 100);
};
This works great in a popup window. I need a pretty popup so i decided to use sweetalert2.
New code:
Swal.fire("👎 Game Over. Try again!");
But now "OK" button does not run the function Restart.
Assuming that restart
is a function that restarts the game, you could write the alert as follows:
Swal.fire("👎 Game Over. Try again!").then(() => {
restart();
});
You would also want to remove the logic from the restart
function that previously fired an alert.