File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
projects/dice-roll-simulator Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 1111 < h1 > Dice Roll Simulator</ h1 >
1212 < div class ="dice " id ="dice "> ⚄</ div >
1313 < 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 >
1816 < script src ="index.js "> </ script >
1917 </ body >
2018</ html >
Original file line number Diff line number Diff line change 11const buttonEl = document . getElementById ( "roll-button" ) ;
2-
2+ const resetButtonEl = document . getElementById ( "reset-button" ) ;
33const diceEl = document . getElementById ( "dice" ) ;
4-
54const rollHistoryEl = document . getElementById ( "roll-history" ) ;
65
76let 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 = "⚄" ; // Reset the dice face to the default
58+ } ) ;
You can’t perform that action at this time.
0 commit comments