From 22da5856cbc6ef943868047ef2c1e7829107f28a Mon Sep 17 00:00:00 2001 From: Prachit707 Date: Thu, 22 Aug 2024 09:23:48 +0530 Subject: [PATCH] Fixed issue #37: Reset button is added --- projects/dice-roll-simulator/index.html | 6 ++---- projects/dice-roll-simulator/index.js | 9 +++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/projects/dice-roll-simulator/index.html b/projects/dice-roll-simulator/index.html index edf81b5..7a01d96 100644 --- a/projects/dice-roll-simulator/index.html +++ b/projects/dice-roll-simulator/index.html @@ -11,10 +11,8 @@

Dice Roll Simulator

- + + diff --git a/projects/dice-roll-simulator/index.js b/projects/dice-roll-simulator/index.js index 8deecde..69718a6 100644 --- a/projects/dice-roll-simulator/index.js +++ b/projects/dice-roll-simulator/index.js @@ -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 = []; @@ -51,3 +50,9 @@ buttonEl.addEventListener("click", () => { rollDice(); }, 1000); }); + +resetButtonEl.addEventListener("click", () => { + historyList = []; + rollHistoryEl.innerHTML = ""; + diceEl.innerHTML = "⚄"; // Reset the dice face to the default +});