-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspscgame.js
More file actions
38 lines (38 loc) · 850 Bytes
/
spscgame.js
File metadata and controls
38 lines (38 loc) · 850 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
const You= prompt("Enter any one of this: stone,paper,scissor");
console.log("your chioce:"+ You);
console.log("Opponent choice:")
let Opponent=Math.floor(Math.random() * 3);
if (Opponent==0){
Opponent="stone";
}
else if (Opponent==1) {
Opponent="paper";
}
else {
Opponent="scissor";
}
console.log(Opponent);if (You==Opponent)
{
console.log("bothwins!");
}
else if(You=="stone"&&Opponent=="paper"){
console.log("Opponent wins!");
}
else if(You=="stone"&&Opponent=="scissor"){
console.log("You wins!");
}
else if(You=="paper"&&Opponent=="scissor"){
console.log("Opponent wins!");
}
else if(You=="paper"&&Opponent=="stone"){
console.log("You wins!");
}
else if(You=="scissor"&&Opponent=="paper"){
console.log("You wins!");
}
else if(You=="scissor"&&Opponent=="stone"){
console.log("Opponent wins!");
}
else{
console.log("please enter a valid input");
}