-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
60 lines (49 loc) · 1.35 KB
/
Copy pathscript.js
File metadata and controls
60 lines (49 loc) · 1.35 KB
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
let choices = ["r", "p", "s"];
let userInput = prompt("Choose r, p or s");
let computerInput = Math.floor(Math.random() * 3); //Picks a random number from 0,1,2
let computerString;
if (computerInput == "0") {
computerString = "r";
} else if (computerInput == "1") {
computerString = "p";
} else computerString = "s";
let userWins = 0;
let userLoses = 0;
let ties = 0;
if (userInput == null || userInput == "") {
text = "User cancelled the prompt.";
console.log(text);
} else
if (userInput === computerString) {
text = "It's a tie";
console.log(text);
ties++;
console.log(ties);
} else {
switch (computerInput) {
case 0:
text = "Off";
break;
case 1:
text = "On";
break;
default:
text = "No value found";
}
}
// if (userInput == null || userInput == "" || userInput !== "r" || userInput !== "s" || userInput !== "p") {
// text = "You need to enter R P or S to play this game.";
// } else {
// text = ;
// }
// let x = "0";
// switch (x) {
// case 0:
// text = "Off";
// break;
// case 1:
// text = "On";
// break;
// default:
// text = "No value found";
// }