From 8648596c05d9a7eac9c0ed6e76c95e3eb4b292a6 Mon Sep 17 00:00:00 2001 From: lolabird Date: Tue, 7 Nov 2023 17:34:34 -0700 Subject: [PATCH] Get buttons to respond --- script.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/script.js b/script.js index ae0bc7e..c4a63f1 100644 --- a/script.js +++ b/script.js @@ -1,8 +1,3 @@ -function getPlayerChoice(){ - let ps = prompt("Rock, Paper, or Scissors?") - - return ps; -} function getComputerChoice(){ let compAnswer = Math.floor(Math.random() * 3) + 1; @@ -46,10 +41,18 @@ function playRound(playerSelection, computerSelection){ } } -function game() { +function game(ps) { let p = 0; let c = 0; + const buttons = document.querySelectorAll('button'); + + buttons.forEach((button) => { + button.addEventListener('click', () => { + console.log(button.id); + }); + }); + while (p < 5 && c < 5) { const ps = getPlayerChoice(); const cs = getComputerChoice();