I have made the game Connect four. When i use an alert to show the winner, the alert box pops up before the last piece is placed. Therefore i would like to use the DOM to announce the winner.
I have made a <div id="winPlayer1">Red Wins!</div>
in HTML
And my JS looks like this:
function gameOver() {
if (activePlayer == 0) {
document.getElementById("winPlayer1").innerHTML;
} else {
pdocument.getElementById("winPlayer2").innerHTML;
}
gameActive = false;
}
How do i get the message to pop up when there is a winner?
Now they are both shown on the page even when there is no winner.