File tree 2 files changed +9
-6
lines changed
projects/dice-roll-simulator
2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 11
11
< h1 > Dice Roll Simulator</ h1 >
12
12
< div class ="dice " id ="dice "> ⚄</ div >
13
13
< button id ="roll-button "> Roll Dice</ button >
14
- < ul id ="roll-history ">
15
- <!-- <li>Roll 1: <span>⚀</span></li>
16
- <li>Roll 2: <span>⚄</span></li> -->
17
- </ ul >
14
+ < button id ="reset-button "> Reset</ button >
15
+ < ul id ="roll-history "> </ ul >
18
16
< script src ="index.js "> </ script >
19
17
</ body >
20
18
</ html >
Original file line number Diff line number Diff line change 1
1
const buttonEl = document . getElementById ( "roll-button" ) ;
2
-
2
+ const resetButtonEl = document . getElementById ( "reset-button" ) ;
3
3
const diceEl = document . getElementById ( "dice" ) ;
4
-
5
4
const rollHistoryEl = document . getElementById ( "roll-history" ) ;
6
5
7
6
let historyList = [ ] ;
@@ -51,3 +50,9 @@ buttonEl.addEventListener("click", () => {
51
50
rollDice ( ) ;
52
51
} , 1000 ) ;
53
52
} ) ;
53
+
54
+ resetButtonEl . addEventListener ( "click" , ( ) => {
55
+ historyList = [ ] ;
56
+ rollHistoryEl . innerHTML = "" ;
57
+ diceEl . innerHTML = "⚄" ; // Reset the dice face to the default
58
+ } ) ;
You can’t perform that action at this time.
0 commit comments