Play a single round of Rock Paper Scissors
This commit is contained in:
parent
9fa14ccf09
commit
97544cafe5
36
script.js
36
script.js
@ -39,12 +39,38 @@ function getComputerChoice(){
|
||||
return computer;
|
||||
}
|
||||
|
||||
console.log(getComputerChoice());
|
||||
|
||||
function playRound(playerSelection, computerSelection){
|
||||
if (playerSelection = "rock" && computerSelection == "paper"){
|
||||
let result = "It's a Tie!";
|
||||
|
||||
if (playerSelection === "rock" && computerSelection == "paper"){
|
||||
console.log(playerSelection, computerSelection);
|
||||
return result = "You Lose! Paper beats Rock";
|
||||
}
|
||||
else if(playerSelection = "paper" && computerSelection == "scissors")
|
||||
//"You Lose! Paper beats Rock"
|
||||
}
|
||||
else if(playerSelection === "paper" && computerSelection == "rock"){
|
||||
console.log(playerSelection, computerSelection);
|
||||
return result = "You Win! Paper beats Rock";
|
||||
}
|
||||
else if(playerSelection === "paper" && computerSelection == "scissors"){
|
||||
console.log(playerSelection, computerSelection);
|
||||
return result = "You Lose! Scissors beats Paper";
|
||||
}
|
||||
else if(playerSelection === "scissors" && computerSelection == "paper"){
|
||||
console.log(playerSelection, computerSelection);
|
||||
return result = "You Win! Scissors beats Paper";
|
||||
}
|
||||
else if(playerSelection === "rock" && computerSelection == "scissors"){
|
||||
console.log(playerSelection, computerSelection);
|
||||
return result = "You Win! Rock beats Scissors";
|
||||
}
|
||||
else if(playerSelection === "scissors" && computerSelection == "rock"){
|
||||
console.log(playerSelection, computerSelection);
|
||||
return result = "You Lose! Rock beats Scissors";
|
||||
}
|
||||
else{
|
||||
console.log(playerSelection, computerSelection);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
console.log(playRound("Paper", getComputerChoice()));
|
||||
|
Loading…
Reference in New Issue
Block a user