-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
28 lines (26 loc) · 859 Bytes
/
script.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
let user = prompt("Please Enter your choice (🐍)s ,(🌊)w OR(🔫)g..");
let cpui = Math.floor(Math.random()*3);
let arr = ['s', 'w', 'g']
let cpu = arr[cpui]
console.log(cpu)
const match = (cpu, user)=> {
if (cpu == user) {
return "Nobody. Match is tied";
} else if (cpu == "s" && user == "w") {
return "cpu";
} else if (cpu == "s" && user == "g") {
return "user";
} else if (cpu == "w" && user == "s") {
return "user";
} else if (cpu == "w" && user == "g") {
return "cpu";
} else if (cpu == "g" && user == "s") {
return "cpu";
} else if (cpu == "g" && user == "w") {
return "user";
}
}
let result = match(cpu, user);
//let game = document.querySelector('.game')
document.write(`CPU🖥️ :- ${cpu} <br> User👨💼 :- ${user} <br>Winner is : ${result}...🏆`);
document.body.style.background = "black";