-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (47 loc) · 1.62 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
var random_dice=Math.floor(Math.random() * 6)+1;
var random_dice1=Math.floor(Math.random() * 6)+1;
if(random_dice>random_dice1){
document.querySelector("h1").innerHTML="🚩Player 1 Wins";
}
else if(random_dice<random_dice1){
document.querySelector("h1").innerHTML="Player 2 Wins🚩";
}
else{
document.querySelector("h1").innerHTML="Draw";
}
if(random_dice===1){
document.querySelectorAll("img")[0].setAttribute("src","images/dice1.png");
}
else if(random_dice===2){
document.querySelectorAll("img")[0].setAttribute("src","images/dice2.png");
}
else if(random_dice===3){
document.querySelectorAll("img")[0].setAttribute("src","images/dice3.png");
}
else if(random_dice===4){
document.querySelectorAll("img")[0].setAttribute("src","images/dice4.png");
}
else if(random_dice===5){
document.querySelectorAll("img")[0].setAttribute("src","images/dice5.png");
}
else{
document.querySelectorAll("img")[0].setAttribute("src","images/dice6.png");
}
if(random_dice1===1){
document.querySelectorAll("img")[1].setAttribute("src","images/dice1.png");
}
else if(random_dice1===2){
document.querySelectorAll("img")[1].setAttribute("src","images/dice2.png");
}
else if(random_dice1===3){
document.querySelectorAll("img")[1].setAttribute("src","images/dice3.png");
}
else if(random_dice1===4){
document.querySelectorAll("img")[1].setAttribute("src","images/dice4.png");
}
else if(random_dice1===5){
document.querySelectorAll("img")[1].setAttribute("src","images/dice5.png");
}
else{
document.querySelectorAll("img")[1].setAttribute("src","images/dice6.png");
}