Datasets:
Commit
·
3084fc2
1
Parent(s):
a3e4e7a
Upload 5 files
Browse files- breakfast.jpg +3 -0
- bridge.jpg +3 -0
- bunny.jpg +3 -0
- castle.jpg +3 -0
- js-game/index.js +41 -0
breakfast.jpg
ADDED
|
Git LFS Details
|
bridge.jpg
ADDED
|
Git LFS Details
|
bunny.jpg
ADDED
|
Git LFS Details
|
castle.jpg
ADDED
|
Git LFS Details
|
js-game/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
const readline = require("readline").createInterface({
|
| 4 |
+
input: process.stdin,
|
| 5 |
+
output: process.stdout,
|
| 6 |
+
});
|
| 7 |
+
|
| 8 |
+
const arr = ["rock", "paper", "sicssor"];
|
| 9 |
+
const ai = arr[Math.floor(Math.random() * arr.length)];
|
| 10 |
+
|
| 11 |
+
readline.question(
|
| 12 |
+
"rock, paper, sicssor, which one you choose? ",
|
| 13 |
+
(yourChoice) => {
|
| 14 |
+
if (yourChoice === "rock") {
|
| 15 |
+
if (ai === "paper") {
|
| 16 |
+
console.log("You lose");
|
| 17 |
+
} else if (ai === "sicssor") {
|
| 18 |
+
console.log("You win");
|
| 19 |
+
} else {
|
| 20 |
+
console.log("It's tie");
|
| 21 |
+
}
|
| 22 |
+
} else if (yourChoice === "paper") {
|
| 23 |
+
if (ai === "paper") {
|
| 24 |
+
console.log("It's tie");
|
| 25 |
+
} else if (ai === "sicssor") {
|
| 26 |
+
console.log("You lose");
|
| 27 |
+
} else {
|
| 28 |
+
console.log("You win");
|
| 29 |
+
}
|
| 30 |
+
} else if (yourChoice === "sicssor") {
|
| 31 |
+
if (ai === "paper") {
|
| 32 |
+
console.log("You win");
|
| 33 |
+
} else if (ai === "sicssor") {
|
| 34 |
+
console.log("It's tie");
|
| 35 |
+
} else {
|
| 36 |
+
console.log("You lose");
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
readline.close();
|
| 40 |
+
}
|
| 41 |
+
);
|