2023-09-30 10:23:21 -06:00
|
|
|
function getComputerChoice(){
|
|
|
|
|
// get random number between 1 and 3
|
|
|
|
|
// if 1, return "rock"
|
|
|
|
|
// if 2, return "paper"
|
|
|
|
|
// if 3, return "scissors"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function playRound(playerSelection, computerSelection){
|
|
|
|
|
//p = playerSelection.toLowerCase()
|
|
|
|
|
//c = computerSelection.toLowerCase()
|
|
|
|
|
|
|
|
|
|
// if player && comp === "rock", || if p && c === "paper" || p && c === "scissors" return "tie"
|
|
|
|
|
|
|
|
|
|
//else if p === "rock"
|
|
|
|
|
//if c === "paper" player loses
|
|
|
|
|
//else if c === "scissors" player wins
|
|
|
|
|
//else if p === "paper"
|
|
|
|
|
//if c === "scissors" player loses
|
|
|
|
|
//if c === "rock" player wins
|
|
|
|
|
//else (p === scissors)
|
|
|
|
|
//if c === "rock" player loses
|
|
|
|
|
//if c === "paper" player wins
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function game(playerSelection, computerSelection) {
|
|
|
|
|
// for (var i = 0; i < 5; i++)
|
|
|
|
|
//playRound(playerSelection, computerSelection)
|
|
|
|
|
|
|
|
|
|
//count how many times p and c have won
|
|
|
|
|
|
|
|
|
|
//return whether or not p has won
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// const ps = prompt("Rock, Paper or Scissors?")
|
|
|
|
|
// const cs = getComputerChoice()
|
|
|
|
|
|
|
|
|
|
//console.log(game(ps, cs)) -
|