-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
32 lines (27 loc) · 1.14 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function computerPlay() {
let options = ["rock", "paper", "scissors"];
return options[Math.floor(Math.random()*options.length)];
}
function playerSelection() {
let playerPlay = prompt ("Enter rock, paper or scissors");
playerPlay.toLowerCase();
return playerPlay;
}
function playRound(playerSelection, computerSelection) {
computerSelection = computerPlay;
if (playerSelection === computerSelection) {
return "It's a tie!";
} else if (playerSelection === "rock" && computerSelection === "paper") {
return "You lose! Paper beats rock";
} else if (playerSelection === "paper" && computerSelection === "rock") {
return "You win! Paper beats rock";
} else if (playerSelection === "rock" && computerSelection === "scissors") {
return "You win! Rock beats scissors";
} else if (playerSelection === "scissors" && computerSelection === "rock") {
return "You lose! Rock beats paper";
} else if (playerSelection === "paper" && computerSelection === "scissors") {
return "You lose! Scissors beats paper!";
} else {
return "You win! Scissors beats paper!"
}
}