-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rock, Paper Scissors.html
163 lines (144 loc) · 5.47 KB
/
Rock, Paper Scissors.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<!DOCTYPE html>
<!-- saved from url=(0054)http://127.0.0.1:5500/html/0.6-rock-paper-scissor.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Rock, Paper Scissors</title>
</head>
<body data-new-gr-c-s-check-loaded="14.1147.0" data-gr-ext-installed="">
<p>Rock Paper Scissors</p>
<button onclick="
const randomNumber = Math.random()
let computerMove = '';
const k = {
rock: '✊',
paper: '✋',
scissors: '>8',
}
if (randomNumber >= 0 && randomNumber < 1/3) {
computerMove = k.rock;
} else if (randomNumber >= 1/3 && randomNumber < 2/3) {
computerMove = k.paper;
} else if (randomNumber >= 2/3 && randomNumber < 1) {
computerMove = k.scissors
}
console.log(computerMove)
let result = '';
if (computerMove === k.rock) {
result = 'Tie.';
} else if (computerMove === k.paper) {
result = 'You lose.';
} else if (computerMove === k.scissors) {
result = 'You won.';
}
alert(`You picked ✊. Computer picked ${computerMove}. ${result}`)
">Rock</button>
<button onclick="
const randomNumber = Math.random()
let computerMove = '';
const k = {
rock: 'rock',
paper: 'paper',
scissors: '>8',
}
if (randomNumber >= 0 && randomNumber < 1/3) {
computerMove = k.rock;
} else if (randomNumber >= 1/3 && randomNumber < 2/3) {
computerMove = k.paper;
} else if (randomNumber >= 2/3 && randomNumber < 1) {
computerMove = k.scissors;
}
let result = '';
if (computerMove === k.rock) {
result = 'You win.';
} else if (computerMove === k.paper) {
result = 'Tie.';
} else if (computerMove === k.scissors) {
result = 'You lost.';
}
alert(`You picked Paper. Computer picked ${computerMove}. ${result}`)
">Paper</button>
<button onclick="
const randomNumber = Math.random()
let computerMove = '';
const k = {
rock: 'rock',
paper: 'paper',
scissors: '>8',
}
if (randomNumber >= 0 && randomNumber < 1/3) {
computerMove = k.rock;
} else if (randomNumber >= 1/3 && randomNumber < 2/3) {
computerMove = k.paper;
} else if (randomNumber >= 2/3 && randomNumber < 1) {
computerMove = k.scissors;
}
console.log(computerMove)
let result = '';
if (computerMove === k.rock) {
result = 'You lose';
} else if (computerMove === k.paper) {
result = 'You won';
} else if (computerMove === k.scissors) {
result = 'Tie.';
}
alert(`You picked >8. Computer picked ${computerMove}. ${result}`)
">Scissors</button>
<script>
</script>
<!-- Code injected by live-server -->
<script>
// <![CDATA[ <-- For SVG support
if ('WebSocket' in window) {
(function () {
function refreshCSS() {
var sheets = [].slice.call(document.getElementsByTagName("link"));
var head = document.getElementsByTagName("head")[0];
for (var i = 0; i < sheets.length; ++i) {
var elem = sheets[i];
var parent = elem.parentElement || head;
parent.removeChild(elem);
var rel = elem.rel;
if (elem.href && typeof rel != "string" || rel.length == 0 || rel.toLowerCase() == "stylesheet") {
var url = elem.href.replace(/(&|\?)_cacheOverride=\d+/, '');
elem.href = url + (url.indexOf('?') >= 0 ? '&' : '?') + '_cacheOverride=' + (new Date().valueOf());
}
parent.appendChild(elem);
}
}
var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://';
var address = protocol + window.location.host + window.location.pathname + '/ws';
var socket = new WebSocket(address);
socket.onmessage = function (msg) {
if (msg.data == 'reload') window.location.reload();
else if (msg.data == 'refreshcss') refreshCSS();
};
if (sessionStorage && !sessionStorage.getItem('IsThisFirstTime_Log_From_LiveServer')) {
console.log('Live reload enabled.');
sessionStorage.setItem('IsThisFirstTime_Log_From_LiveServer', true);
}
})();
}
else {
console.error('Upgrade your browser. This Browser is NOT supported WebSocket for Live-Reloading.');
}
// ]]>
</script>
</body><grammarly-desktop-integration data-grammarly-shadow-root="true"><template shadowrootmode="open"><style>
div.grammarly-desktop-integration {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select:none;
user-select:none;
}
div.grammarly-desktop-integration:before {
content: attr(data-content);
}
</style><div aria-label="grammarly-integration" role="group" tabindex="-1" class="grammarly-desktop-integration" data-content="{"mode":"full","isActive":true,"isUserDisabled":false}"></div></template></grammarly-desktop-integration></html>