-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
55 lines (44 loc) · 1.45 KB
/
index.html
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
50
51
52
53
54
55
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Dicee Chance Game</title>
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css?family=Indie+Flower|Lobster" rel="stylesheet">
</head>
<body>
<div class="container">
<h1>Refresh Me</h1>
<div class="dice">
<p>Player 1</p>
<img class="img1" id="img1" src="images/dice6.png">
</div>
<div class="dice">
<p>Player 2</p>
<img class="img2" id="img2" src="images/dice6.png">
</div>
</div>
<script>
var img1 = document.getElementById("img1")
var img2 = document.getElementById("img2")
var imgArray = ["images/dice1.png", "images/dice2.png", "images/dice3.png", "images/dice4.png", "images/dice5.png", "images/dice6.png"];
var picker1 = Math.floor(Math.random() * 6)
var picker2 = Math.floor(Math.random() * 6)
var setImage1 = imgArray[picker1];
var setImage2 = imgArray[picker2];
img2.setAttribute("src", setImage2)
img1.setAttribute("src", setImage1)
var h1 = document.querySelector("h1");
if (picker1 > picker2) {
h1.textContent = "Player 1 wins!"
} else if (picker2 > picker1) {
h1.textContent = "Player 2 wins!"
} else {
h1.textContent = "Oops, it's a draw!"
}
</script>
</body>
<footer>
Made by 🎲 Esther Ohiomame 🎲
</footer>
</html>