-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
49 lines (49 loc) · 1.5 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta
http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport"
content="width=device-width,
initial-scale=1.0">
<title>Document</title>
<link rel="style.css">
</head>
<body>
<h1>Dirk's Dice Doller!</h1>
<button onclick="rollDice()">Roller Dice</button>
</body>
<h2 id="lucky">Your lucky number: </h2>
<h2 id="myroll">Your roll:</h2>
<script>
function rollDice(){
var luckyNumber = Math.floor(Math.random()
* 6 + 1);
// We also need our number
var myRoll = Math.floor
(Math.random() * 6 + 1);
// Show our numbers
document.getElementById
("lucky").innerText =
"Your lucky number: " +
luckyNumber;
document.getElementById
("myroll").innerText =
"Your roll: " + myRoll;
// We need to know if they are equal
if(luckyNumber == myRoll){
// If they are equal give a visual Won!
document.getElementById
("result").innerText =
"You won!!";
} else {
// If they are not equal, give a visual that we need to try again
document.getElementById
("result").innerText =
"Try again...";
}
}
</script>
</html>