@@ -8,7 +8,7 @@ const operators = document.querySelectorAll("[data-operator]");
88const clearHistoryBtn = document . querySelector ( ".clear-history-btn" ) ;
99
1010
11- console . log ( computationHistoryParent ) ;
11+ console . log ( clearHistoryBtn ) ;
1212
1313
1414
@@ -60,6 +60,8 @@ btns.forEach((btn) => {
6060
6161 convertToPercentage ( buttonValue ) ;
6262
63+
64+
6365
6466 } ) ;
6567} ) ;
@@ -70,6 +72,12 @@ function convertToPercentage(button) {
7072 }
7173}
7274
75+ clearHistoryBtn . addEventListener ( "click" , ( ) => {
76+
77+ historyElement . innerHTML = ""
78+ console . log ( historyElement . childElementCount )
79+ } )
80+
7381function deteLastEntry ( button ) {
7482 if ( button === "DE" ) {
7583 let newArray = data . slice ( ZERO , - 1 ) ;
@@ -226,7 +234,9 @@ function userClicksOnEqualButton(button) {
226234 data = [ ] ;
227235 data . push ( result ) ;
228236
229- createHistoryList ( historyEntries , historyElement , history )
237+ createHistoryList ( historyEntries , historyElement , history ) ;
238+
239+ togglesClearHistoryButton ( historyElement , clearHistoryBtn ) ;
230240
231241 // debugger
232242
@@ -280,13 +290,16 @@ function createHistoryList(array, element, history) {
280290 if ( element . childElementCount > HISTORY_LIMIT ) {
281291 element . firstElementChild . remove ( ) ;
282292 }
283- if ( element . childElementCount > 0 ) {
284- clearHistoryBtn . classList . toggle ( "display" ) ;
285- console . log ( historyElement . childElementCount )
286- }
293+
287294
288295 } ) ;
289296}
290297
298+ function togglesClearHistoryButton ( element , btn ) {
299+ if ( element . childElementCount > 0 ) {
300+ btn . classList . toggle ( "display" ) ;
301+ }
302+ }
303+
291304
292305// functions creations ends
0 commit comments