Add game reset functionality

This commit is contained in:
lolabird 2023-11-08 00:20:16 -07:00
commit 9ee116f1f0
2 changed files with 11 additions and 2 deletions

View file

@ -87,7 +87,7 @@ function game() {
}
function endGame(){
function endGame() {
let winner = (pScore > cScore) ? true : false;
const newGame = document.createElement("button");
const newDiv = document.createElement("div");
@ -100,6 +100,15 @@ function endGame(){
newGame.textContent = "Play Again?";
newGame.classList.add("button");
newGame.addEventListener("click", resetGame);
newDiv.appendChild(newGame);
msg.appendChild(newDiv);
}
function resetGame() {
pScore = 0;
cScore = 0;
player.textContent = "0";
computer.textContent = "0";
msg.textContent = "";
}

View file

@ -17,7 +17,7 @@ h1{
justify-content: center;
}
.button, #msg .button {
.button {
width: 200px;
margin: 5px;
font-size: 30px;