loading
index.js
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
var player1 = prompt("Choose Rock, Paper, or Scissors ");
var x = Math.random();
 
if (x < 1/3){
  x = "rock";
} else if(x <= 2/3) {
   x = "paper";
} else {
  x = "scissors";
}
 
var result = function(a, b) {
   if(a === b) {
   return "It's a draw";
}
if(a === "rock") {
   if(b === "scissors") {
       return "rock wins";
   } else {
       return "paper wins";
   }
}
if(a === "paper") {
   if(b === "rock") {
       return "paper wins";
   } else {
       if(b === "scissors") {
         return "scissors wins";
   }
}
if(a === "scissors") {
   if(b === "rock") {
       return "rock wins";
   } else {
       if(b === "paper") {
           return "scissors wins";
       }
   }
}
}
};
console.log("Player1: " + player1);
console.log("x: " + x);
result(player1, x);
Fetching token