-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
21 lines (21 loc) · 730 Bytes
/
index.js
File metadata and controls
21 lines (21 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var ran1 = Math.floor((Math.random()) * 6) + 1;
var ran2 = Math.floor((Math.random()) * 6) + 1;
console.log(ran1, ran2);
var image1 = document.querySelector(".sub1 img");
var image2 = document.querySelector(".sub2 img");
image1.setAttribute("src", "dices\\" + ran1 + ".png");
image2.setAttribute("src", "dices\\" + ran2 + ".png");
var result1 = document.querySelector(".sub1 .result");
var result2 = document.querySelector(".sub2 .result");
if (ran1 > ran2) {
result1.textContent = "WINNER!!!"
result2.style.display = "none"
}
else if (ran1 < ran2) {
result2.textContent = "WINNER!!!"
result1.style.display = "none"
}
else {
result1.textContent = "DRAW"
result2.textContent = "DRAW"
}