-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (35 loc) · 1.01 KB
/
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
46
47
48
49
function checkRefresh() {
if (!sessionStorage.getItem("stone")) {
sessionStorage.setItem("stone", "extra")
} else(
game()
)
}
function game(){
// document.querySelector("button").addEventListener("click",function(){
// })
var randomNumber1 =Math.floor(Math.random()*3+1);
var randomNumber2 =Math.floor(Math.random()*3+1);
document.querySelector(".img1").setAttribute("src","images/image"+randomNumber1+".png");
document.querySelector(".img2").setAttribute("src","images/image"+randomNumber2+".png");
var x=randomNumber1;
var y=randomNumber2;
var result;
if(x!=3 && y==x+1)
{
result="<i class='fas fa-trophy'></i> Player-2 Wins ";
}
else if(x==3 && y==1)
{
result= "Player-2 Wins <i class='fas fa-trophy'></i>";
}
else if(x==y)
{
result="!Draw";
}
else{
result="<i class='fas fa-trophy'></i> Player1 Wins "
}
document.querySelector("h1").innerHTML=result;
}
document.querySelector("body").onload = checkRefresh();