Get buttons to respond
This commit is contained in:
parent
4301364cbb
commit
8648596c05
1 changed files with 9 additions and 6 deletions
15
script.js
15
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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue