-
Notifications
You must be signed in to change notification settings - Fork 0
/
paper.html
101 lines (75 loc) · 2.73 KB
/
paper.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p>Rock Paper Scissors</p>
<button onclick="
const randomNumber = Math.random()
let computerMove = '';
if (randomNumber >= 0 && randomNumber < 1 / 3){
computerMove = 'rock';
} else if (randomNumber >= 1 / 3 && randomNumber < 2 / 3){
computerMove ='paper';
} else if(randomNumber >- 2 / 3 && randomNumber < 1){
computerMove ='scissors';
}
let result = '';
if (computerMove === 'rock') {
result = 'tie';
}else if (computerMove === 'paper'){
result = 'You lose';
} else if (computerMove === 'scissors'){
result = 'You win';
}
alert(`You picked rock. Computer picked ${computerMove}. ${result}`);
">Rock</button>
<button onclick="
const randomNumber = Math.random()
let computerMove = '';
if (randomNumber >= 0 && randomNumber < 1 / 3){
computerMove = 'rock';
} else if (randomNumber >= 1 / 3 && randomNumber < 2 / 3){
computerMove ='paper';
} else if(randomNumber >- 2 / 3 && randomNumber < 1){
computerMove ='scissors';
}
let result = '';
if (computerMove === 'rock') {
result = 'You win';
}else if (computerMove === 'paper'){
result = 'Tie';
} else if (computerMove === 'scissors'){
result = 'You lose';
}
alert(`You picked Paper. Computer picked ${computerMove}. ${result}`);
">Paper</button>
<button onclick="
const randomNumber = Math.random()
let computerMove = '';
if (randomNumber >= 0 && randomNumber < 1 / 3){
computerMove = 'rock';
} else if (randomNumber >= 1 / 3 && randomNumber < 2 / 3){
computerMove ='paper';
} else if(randomNumber >- 2 / 3 && randomNumber < 1){
computerMove ='scissors';
}
let result = '';
if (computerMove === 'rock') {
result = 'You lose';
}else if (computerMove === 'paper'){
result = 'You win';
} else if (computerMove === 'scissors'){
result = 'Tie';
}
alert(`You picked Scissors. Computer picked ${computerMove}. ${result}`);
if (5) {
console.log('truthy')
}
">Scissors</button>
</body>
</html>