Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue #37: Reset button is added #43

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions projects/dice-roll-simulator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
<h1>Dice Roll Simulator</h1>
<div class="dice" id="dice">&#9860;</div>
<button id="roll-button">Roll Dice</button>
<ul id="roll-history">
<!-- <li>Roll 1: <span>&#9856;</span></li>
<li>Roll 2: <span>&#9860;</span></li> -->
</ul>
<button id="reset-button">Reset</button>
<ul id="roll-history"></ul>
<script src="index.js"></script>
</body>
</html>
9 changes: 7 additions & 2 deletions projects/dice-roll-simulator/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const buttonEl = document.getElementById("roll-button");

const resetButtonEl = document.getElementById("reset-button");
const diceEl = document.getElementById("dice");

const rollHistoryEl = document.getElementById("roll-history");

let historyList = [];
Expand Down Expand Up @@ -51,3 +50,9 @@ buttonEl.addEventListener("click", () => {
rollDice();
}, 1000);
});

resetButtonEl.addEventListener("click", () => {
historyList = [];
rollHistoryEl.innerHTML = "";
diceEl.innerHTML = "&#9860;"; // Reset the dice face to the default
});