File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -105,9 +105,8 @@ btns.forEach((btn) => {
105105 if ( buttonValue === "=" ) {
106106 try {
107107 let result = eval ( data . join ( "" ) ) ;
108- data = [ ] ;
109- data . push ( result ) ;
110- divideByZero ( screen , result )
108+ displayResult ( data , result ) ;
109+ divideByZero ( screen , result ) ;
111110 } catch ( e ) {
112111 screen . innerText = `${ e . name } press AC` ;
113112 }
@@ -116,7 +115,12 @@ btns.forEach((btn) => {
116115 function divideByZero ( display , outcome ) {
117116 outcome === Infinity
118117 ? ( display . innerText = "Math Error. Cannot divide by zero" )
119- : ( display . innerText = outcomet ) ;
118+ : ( display . innerText = outcome ) ;
119+ }
120+ function displayResult ( array , outcome ) {
121+ array = [ ] ;
122+ array . push ( outcome ) ;
123+
120124 }
121125
122126 if ( buttonValue === "%" ) {
You can’t perform that action at this time.
0 commit comments