@@ -3,11 +3,6 @@ let screen = document.querySelector("[data-screen]");
33const operators = document . querySelectorAll ( "[data-operator]" ) ;
44const operatorRegex = / [ \/ * \- + ] / ;
55
6-
7-
8-
9-
10-
116let data = [ ] ;
127
138btns . forEach ( ( btn ) => {
@@ -36,15 +31,10 @@ btns.forEach((btn) => {
3631
3732 convertToPercentage ( buttonValue ) ;
3833
39- userClicksOnEqualButton ( buttonValue )
40-
34+ userClicksOnEqualButton ( buttonValue ) ;
4135 } ) ;
4236} ) ;
43-
44- // end of forEach() statement
45-
46- // functions creations
47-
37+ // forEach ends & functions creations begins
4838function convertToPercentage ( button ) {
4939 if ( button === "%" ) {
5040 screen . innerText = screen . innerText / 100 ;
@@ -150,7 +140,7 @@ function insertClosingParenthesis(button) {
150140
151141function handlingZeroFollowedByAdecimal ( button ) {
152142 if ( Number ( button ) === 0 && screen . innerText . startsWith ( "0." ) ) {
153- screen . innerText += buttonValue ;
143+ screen . innerText += button ;
154144 }
155145}
156146
@@ -174,10 +164,6 @@ function handleNumberButton(button) {
174164 }
175165}
176166
177-
178- //////
179-
180-
181167function userClicksOnEqualButton ( button ) {
182168 if ( button === "=" ) {
183169 try {
@@ -196,9 +182,7 @@ function userClicksOnEqualButton(button) {
196182 console . log ( result ) ;
197183 displayResult ( replacedArray , result ) ;
198184 screen . innerText =
199- result === Infinity
200- ? "You cannot divide by zero. Press AC"
201- : result ;
185+ result === Infinity ? "You cannot divide by zero. Press AC" : result ;
202186 // divideByZero(screen, result);
203187 data = [ ] ;
204188 data . push ( result ) ;
@@ -235,3 +219,4 @@ function displayResult(array, outcome) {
235219 array = [ ] ;
236220 array . push ( outcome ) ;
237221}
222+ // functions creations ends
0 commit comments