Add getPlayerChoice function
This commit is contained in:
parent
6aac048765
commit
4301364cbb
1 changed files with 7 additions and 1 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
function getPlayerChoice(){
|
||||||
|
let ps = prompt("Rock, Paper, or Scissors?")
|
||||||
|
|
||||||
|
return ps;
|
||||||
|
}
|
||||||
|
|
||||||
function getComputerChoice(){
|
function getComputerChoice(){
|
||||||
let compAnswer = Math.floor(Math.random() * 3) + 1;
|
let compAnswer = Math.floor(Math.random() * 3) + 1;
|
||||||
|
|
||||||
|
|
@ -45,7 +51,7 @@ function game() {
|
||||||
let c = 0;
|
let c = 0;
|
||||||
|
|
||||||
while (p < 5 && c < 5) {
|
while (p < 5 && c < 5) {
|
||||||
const ps = prompt("Rock, Paper, or Scissors?");
|
const ps = getPlayerChoice();
|
||||||
const cs = getComputerChoice();
|
const cs = getComputerChoice();
|
||||||
|
|
||||||
play = playRound(ps, cs);
|
play = playRound(ps, cs);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue