-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy path17-rock-paper-scissors.js
More file actions
43 lines (40 loc) · 985 Bytes
/
17-rock-paper-scissors.js
File metadata and controls
43 lines (40 loc) · 985 Bytes
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
// Rock Paper Scissors 🫲
// Codédex
// 0 = Rock
// 1 = Paper
// 2 = Scissors
const player = 2;
const computer = Math.floor(Math.random() * 3);
if (player === 0) {
if (computer === 0) {
console.log("Draw");
} else if (computer === 1) {
console.log("The computer won!");
} else if (computer === 2) {
console.log("The player won!");
} else {
console.log("An error occurred");
}
} else if (player === 1) {
if (computer === 0) {
console.log("The player won!");
} else if (computer === 1) {
console.log("Draw");
} else if (computer === 2) {
console.log("The computer won!");
} else {
console.log("An error occurred");
}
} else if (player === 2) {
if (computer === 0) {
console.log("The computer won!");
} else if (computer === 1) {
console.log("The player won!");
} else if (computer === 2) {
console.log("Draw");
} else {
console.log("An error occurred");
}
} else {
console.log("An error occurred");
}