-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (25 loc) · 946 Bytes
/
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
document.querySelectorAll("img")[0].setAttribute("src", "images/dice6.png");
document.querySelectorAll("img")[1].setAttribute("src", "images/dice6.png");
var random_images_array = [
"images/dice1.png",
"images/dice2.png",
"images/dice3.png",
"images/dice4.png",
"images/dice5.png",
"images/dice6.png",
];
var randomNumber1 = Math.floor(Math.random() * 6);
var randomNumber2 = Math.floor(Math.random() * 6);
document
.querySelectorAll("img")[0]
.setAttribute("src", random_images_array[randomNumber1]);
document
.querySelectorAll("img")[1]
.setAttribute("src", random_images_array[randomNumber2]);
if (randomNumber1 > randomNumber2) {
document.querySelector("h1").innerHTML = "Player 1 Wins🚩 ";
} else if (randomNumber1 < randomNumber2) {
document.querySelector("h1").innerHTML = "Player 2 Wins 🚩";
} else {
document.querySelector("h1").innerHTML = "Draw!";
}