-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
51 lines (48 loc) · 1.67 KB
/
Copy pathscript.js
File metadata and controls
51 lines (48 loc) · 1.67 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
let computerPick=()=>{
let randomNum=Math.floor(Math.random()*3)+1;
if(randomNum===1){
return "rock"
}
else if(randomNum===2){
return "paper"
}
else{
return "secissor"
}
}
let op=document.getElementById("op");
let bt1=document.getElementById("rock");
let bt2=document.getElementById("paper");
let bt3=document.getElementById("secissor");
bt1.addEventListener("click",()=>{
if(computerPick()=="rock"){
op.innerText="your input and computers input is same so it's tie";
}
else if(computerPick()=="paper"){
op.innerText="your input is rock and computer input is paper so you lost this time";
}
else if(computerPick()=="secissor"){
op.innerText="your input is rock and computer input is secissor so win this game";
}
})
bt2.addEventListener("click",()=>{
if(computerPick()=="rock"){
op.innerText="your input is paper and computer input is rock so you won this game";
}
else if(computerPick()=="paper"){
op.innerText="your input and computers input is same so it's tie";
}
else if(computerPick()=="secissor"){
op.innerText="your input is paper and computer input is secissor so you lost this time";
}
})
bt3.addEventListener("click",()=>{
if(computerPick()=="rock"){
op.innerText="Your input is secissor and computer input is rock so you lost this time";
}
else if(computerPick()=="paper"){
op.innerText="your input is secissor and computer input is paper so you won this game";
}
else if(computerPick()=="secissor"){
op.innerText="your input and computers input is same so it's tie";
}})