-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
66 lines (66 loc) · 1.88 KB
/
app.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
let computerDisplay = document.getElementById("computerChoice");
let userDisplay = document.getElementById("YourChoice");
let resultDisplay = document.getElementById("result");
let computerChoice1;
let computerChoice2;
let userChoice;
let result;
function displayComChoice(){
let random = Math.floor(Math.random()*3)+1;
if(random === 1){
computerChoice1 = "rock";
computerChoice2 = "ROCK🪨🪨"
}
if(random === 2){
computerChoice1 = "paper";
computerChoice2 = "PAPER📃📃";
}
if(random === 3){
computerChoice1 = "scissor";
computerChoice2 = "SCISSOR✂️✂️";
}
computerDisplay.innerText = computerChoice2;
}
function rock(){
userChoice = "rock";
userDisplay.innerText = "ROCK🪨🪨";
displayComChoice();
getResult();
}
function paper(){
userChoice = "paper";
userDisplay.innerText = "PAPER📃📃";
displayComChoice();
getResult();
}
function scissor(){
userChoice = "scissor";
userDisplay.innerText = "SCISSOR✂️✂️";
displayComChoice();
getResult();
}
function getResult(){
if(computerChoice1 === userChoice){
result = "Its a Draw🤦♂️🤦♂️"
}
if(computerChoice1 === "rock" && userChoice === "paper"){
result = "You Won!😃😃"
}
if(computerChoice1 === "rock" && userChoice === "scissor"){
result = "Computer Won!😫😫"
}
if(computerChoice1 === "paper" && userChoice === "rock"){
result = "Computer Won!😫😫"
}
if(computerChoice1 === "paper" && userChoice === "scissor"){
result = "You Won!😃😃"
}
if(computerChoice1 === "scissor" && userChoice === "paper"){
result = "Computer Won!😫😫"
}
if(computerChoice1 === "scissor" && userChoice === "rock"){
result = "You Won!😃😃"
}
resultDisplay.innerText = result;
}
//MADE WITH LOVE BY KALPIT JAIN : kalpit86