Skip to content

Commit 22da585

Browse files
committedAug 22, 2024
Fixed issue sahandghavidel#37: Reset button is added
1 parent 9178903 commit 22da585

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed
 

‎projects/dice-roll-simulator/index.html

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
<h1>Dice Roll Simulator</h1>
1212
<div class="dice" id="dice">&#9860;</div>
1313
<button id="roll-button">Roll Dice</button>
14-
<ul id="roll-history">
15-
<!-- <li>Roll 1: <span>&#9856;</span></li>
16-
<li>Roll 2: <span>&#9860;</span></li> -->
17-
</ul>
14+
<button id="reset-button">Reset</button>
15+
<ul id="roll-history"></ul>
1816
<script src="index.js"></script>
1917
</body>
2018
</html>

‎projects/dice-roll-simulator/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const buttonEl = document.getElementById("roll-button");
2-
2+
const resetButtonEl = document.getElementById("reset-button");
33
const diceEl = document.getElementById("dice");
4-
54
const rollHistoryEl = document.getElementById("roll-history");
65

76
let historyList = [];
@@ -51,3 +50,9 @@ buttonEl.addEventListener("click", () => {
5150
rollDice();
5251
}, 1000);
5352
});
53+
54+
resetButtonEl.addEventListener("click", () => {
55+
historyList = [];
56+
rollHistoryEl.innerHTML = "";
57+
diceEl.innerHTML = "&#9860;"; // Reset the dice face to the default
58+
});

0 commit comments

Comments
 (0)