-
Notifications
You must be signed in to change notification settings - Fork 0
/
orginal.html
44 lines (41 loc) · 1.52 KB
/
orginal.html
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
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<html>
<script>
function computerPlay()
{
let play = Math.floor(Math.random() * 3);
return (play === 0) ? "Rock" : (play === 1) ? "Paper" : "Scissors";
}
function playRound(playerSelection, computerSelection)
{
if (playerSelection.toLowerCase() === computerSelection.toLowerCase())
return `You tied with ${computerSelection}.`;
if (playerSelection.toLowerCase() === "rock")
{
if (computerSelection === "Paper")
return "You Lose! Paper beats Rock.";
return "You Win! Rock beats Scissors.";
}
else if (playerSelection.toLowerCase() === "paper")
{
if (computerSelection === "Scissors")
return "You Lose! Scissors beat Paper.";
return "You Win! Paper beats Rock";
}
else if (playerSelection.toLowerCase() === "scissors")
{
if (computerSelection === "Rock")
return "You Lose! Rock beats Scissors.";
return "You Win! Scissors beat Paper.";
}
}
function playerPlay()
{
let play = "";
while (play.toLowerCase() !== "rock" && play.toLowerCase() !==
"paper" && play.toLowerCase() !== "scissors")
play = prompt("Choose Rock, Paper, or Scissors")
return play;
}
</script>
</html>