File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ btns.forEach((btn) => {
2626
2727 handleNumberButton ( buttonValue ) ;
2828
29+ deteLastEntry ( buttonValue ) ;
30+
31+ convertToPercentage ( buttonValue ) ;
32+
2933 function userClicksOnEqualButton ( button ) {
3034 if ( button === "=" ) {
3135 try {
@@ -84,26 +88,29 @@ btns.forEach((btn) => {
8488 array . push ( outcome ) ;
8589 }
8690
87- if ( buttonValue === "%" ) {
88- screen . innerText = screen . innerText / 100 ;
89- }
91+
9092
91- deteLastEntry ( buttonValue ) ;
93+
9294 } ) ;
9395} ) ;
9496
9597// end of forEach() statement
9698
99+ function convertToPercentage ( button ) {
100+ if ( button === "%" ) {
101+ screen . innerText = screen . innerText / 100 ;
102+ }
103+ }
104+
97105function deteLastEntry ( button ) {
98- if ( button === "DE" ) {
106+ if ( button === "DE" ) {
99107 let newArray = data . slice ( 0 , - 1 ) ;
100108 screen . innerText = newArray . join ( "" ) ;
101109 data = newArray ;
102110 if ( screen . innerText === "" ) {
103111 screen . innerText = 0 ;
104112 }
105113 }
106-
107114}
108115
109116function canUserAddDot ( button ) {
You can’t perform that action at this time.
0 commit comments