From a3dc9d8c3ccbff590174abf09208bc02080995b5 Mon Sep 17 00:00:00 2001 From: lolabird Date: Tue, 7 Nov 2023 22:10:15 -0700 Subject: [PATCH] Add endgame message to DOM --- script.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/script.js b/script.js index 77d6745..0abab1c 100644 --- a/script.js +++ b/script.js @@ -77,18 +77,19 @@ function game() { } if (pScore === 5 || cScore === 5) { - console.log(endGame()); + endGame(); } } function endGame(){ - let winner = (pScore > cScore) ? true : false; + const msg = document.querySelector("#msg"); + const span = document.createElement("span"); + let winner = (pScore > cScore) ? true : false; if (winner) { - return "You won the game " + pScore + " to " + cScore + "! Great job!" ; + msg.textContent = "You won the game " + pScore + " to " + cScore + "! Great job!" ; } else { - return "You lost the game " + pScore + " to " + cScore + ". Better luck next time!"; + msg.textContent = "You lost the game " + pScore + " to " + cScore + ". Better luck next time!"; } - } \ No newline at end of file