Compare commits
No commits in common. "bd24adc2d798a853ce0ed7d887834271955c3221" and "97544cafe5b2779bf001652e3a684b494596c43f" have entirely different histories.
bd24adc2d7
...
97544cafe5
72
script.js
72
script.js
@ -42,77 +42,35 @@ function getComputerChoice(){
|
||||
|
||||
function playRound(playerSelection, computerSelection){
|
||||
let result = "It's a Tie!";
|
||||
playerSelection = playerSelection.toLowerCase();
|
||||
|
||||
if (playerSelection === "rock" && computerSelection == "paper"){
|
||||
result = "You Lose! Paper beats Rock";
|
||||
console.log(playerSelection, computerSelection, result);
|
||||
|
||||
return false;
|
||||
console.log(playerSelection, computerSelection);
|
||||
return result = "You Lose! Paper beats Rock";
|
||||
}
|
||||
else if(playerSelection === "paper" && computerSelection == "rock"){
|
||||
result = "You Win! Paper beats Rock";
|
||||
console.log(playerSelection, computerSelection, result);
|
||||
|
||||
return true;
|
||||
console.log(playerSelection, computerSelection);
|
||||
return result = "You Win! Paper beats Rock";
|
||||
}
|
||||
else if(playerSelection === "paper" && computerSelection == "scissors"){
|
||||
result = "You Lose! Scissors beats Paper";
|
||||
console.log(playerSelection, computerSelection, result);
|
||||
|
||||
return false;
|
||||
console.log(playerSelection, computerSelection);
|
||||
return result = "You Lose! Scissors beats Paper";
|
||||
}
|
||||
else if(playerSelection === "scissors" && computerSelection == "paper"){
|
||||
result = "You Win! Scissors beats Paper";
|
||||
console.log(playerSelection, computerSelection, result);
|
||||
|
||||
return true;
|
||||
console.log(playerSelection, computerSelection);
|
||||
return result = "You Win! Scissors beats Paper";
|
||||
}
|
||||
else if(playerSelection === "rock" && computerSelection == "scissors"){
|
||||
result = "You Win! Rock beats Scissors";
|
||||
console.log(playerSelection, computerSelection, result);
|
||||
|
||||
return true;
|
||||
console.log(playerSelection, computerSelection);
|
||||
return result = "You Win! Rock beats Scissors";
|
||||
}
|
||||
else if(playerSelection === "scissors" && computerSelection == "rock"){
|
||||
result = "You Lose! Rock beats Scissors";
|
||||
console.log(playerSelection, computerSelection, result);
|
||||
|
||||
return false;
|
||||
console.log(playerSelection, computerSelection);
|
||||
return result = "You Lose! Rock beats Scissors";
|
||||
}
|
||||
else{
|
||||
console.log(playerSelection, computerSelection,result);
|
||||
return null;
|
||||
console.log(playerSelection, computerSelection);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
// console.log(playRound("Paper", getComputerChoice()));
|
||||
|
||||
function game(){
|
||||
let player = 0;
|
||||
let computer = 0;
|
||||
let win = "You win";
|
||||
|
||||
while (player || computer < 5) {
|
||||
let party = playRound(prompt("Rock, Paper or Scissors?"), getComputerChoice());
|
||||
|
||||
if(party === true){
|
||||
player +=1;
|
||||
}
|
||||
else if(party === false){
|
||||
computer +=1;
|
||||
}
|
||||
|
||||
console.log(`Player score: ${player}/5, Computer score: ${computer}/5`);
|
||||
|
||||
if(player === 5){
|
||||
return win = "You win!";
|
||||
}
|
||||
else if(computer === 5){
|
||||
return win = "Computer wins!";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
console.log(game());
|
||||
console.log(playRound("Paper", getComputerChoice()));
|
||||
|
Loading…
Reference in New Issue
Block a user