-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
20 lines (16 loc) · 819 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
document.querySelector("button").addEventListener("click", Role);
function Role() {
var random1 = Math.floor(Math.random() * 6) + 1;
var randomImageSource1 = "images/dice" + random1 + ".png";
var image1 = document.querySelectorAll("img")[0];
image1.setAttribute("src", randomImageSource1);
var random2 = Math.floor(Math.random() * 6) + 1;
var randomImageSource2 = "images/dice" + random2 + ".png";
var image2 = document.querySelectorAll("img")[1];
image2.setAttribute("src", randomImageSource2);
var random3 = Math.floor(Math.random() * 6) + 1;
var randomImageSource3 = "images/dice" + random3 + ".png";
var image3 = document.querySelectorAll("img")[2];
image3.setAttribute("src", randomImageSource3);
document.querySelector("h1").innerHTML = "Total is " + (random1 + random2 + random3);
}