Add button to play newGame
This commit is contained in:
parent
ab8f3491e0
commit
089bb290e7
2 changed files with 8 additions and 1 deletions
|
|
@ -89,10 +89,17 @@ function game() {
|
||||||
|
|
||||||
function endGame(){
|
function endGame(){
|
||||||
let winner = (pScore > cScore) ? true : false;
|
let winner = (pScore > cScore) ? true : false;
|
||||||
|
const newGame = document.createElement("button");
|
||||||
|
const newDiv = document.createElement("div");
|
||||||
|
|
||||||
if (winner) {
|
if (winner) {
|
||||||
msg.textContent = "You won the game! Great job!";
|
msg.textContent = "You won the game! Great job!";
|
||||||
} else {
|
} else {
|
||||||
msg.textContent = "You lost the game. Better luck next time!";
|
msg.textContent = "You lost the game. Better luck next time!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newGame.textContent = "Play Again?";
|
||||||
|
newGame.classList.add("button");
|
||||||
|
newDiv.appendChild(newGame);
|
||||||
|
msg.appendChild(newDiv);
|
||||||
}
|
}
|
||||||
|
|
@ -17,7 +17,7 @@ h1{
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.button, #msg .button {
|
||||||
width: 200px;
|
width: 200px;
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue