@@ -2,6 +2,7 @@ let historybutton = document.getElementById('historybutton');
22let history = document . getElementById ( 'history' ) ;
33let bar1 = document . getElementById ( 'bar1' ) ;
44let bar2 = document . getElementById ( 'bar2' ) ;
5+ let dis = document . getElementById ( 'answer' ) ;
56
67function showHistory ( ) {
78 let calcHistory = JSON . parse ( localStorage . getItem ( "calcHistory" ) ) || [ ] ;
@@ -15,7 +16,7 @@ function showHistory() {
1516 let historyItem = document . createElement ( 'div' ) ;
1617 historyItem . innerHTML = "There's no history yet." ;
1718 historyItem . className = 'historyelement his' ;
18- historyItem . style . fontSize = '30px ' ;
19+ historyItem . style . fontSize = '25px ' ;
1920 history . appendChild ( historyItem ) ;
2021 } else {
2122 for ( let index = len - 1 ; index >= 0 ; index -- ) {
@@ -27,16 +28,31 @@ function showHistory() {
2728 if ( index > 0 ) history . appendChild ( document . createElement ( 'hr' ) ) ;
2829 }
2930 }
31+
3032 history . style . display = 'block' ;
3133}
3234
3335historybutton . addEventListener ( 'click' , showHistory ) ;
3436
37+ function clearAll ( ) {
38+ dis . value = ''
39+ }
40+
3541function hide ( ) {
3642 history . style . display = 'none' ;
3743 bar1 . style . display = 'none' ;
3844 bar2 . style . display = 'none' ;
3945}
46+ function deleteLastEntry ( ) {
47+ let calcHistory = JSON . parse ( localStorage . getItem ( "calcHistory" ) ) || [ ] ;
48+ if ( calcHistory . length > 0 ) {
49+ calcHistory . pop ( ) ;
50+ localStorage . setItem ( "calcHistory" , JSON . stringify ( calcHistory ) ) ;
51+ showHistory ( ) ; // It open each time when u click on CE if u dont want then u can remove it ....
52+ }
53+ }
54+
55+
4056
4157bar1 . addEventListener ( 'click' , hide ) ;
4258bar2 . addEventListener ( 'click' , hide ) ;
0 commit comments