@@ -4,10 +4,11 @@ const operators = document.querySelectorAll("[data-operator]");
44
55let data = [ ] ;
66
7+
8+
79btns . forEach ( ( btn ) => {
810 btn . addEventListener ( "click" , function ( e ) {
911 let buttonValue = e . target . dataset . value ;
10-
1112 // if (buttonValue === "(") {
1213 // let isOpenParenthesis = true;
1314 // for (let i = data.length - 1; i >= 0; i--) {
@@ -77,7 +78,9 @@ btns.forEach((btn) => {
7778
7879 if ( buttonValue === "=" ) {
7980 try {
81+ console . log ( data )
8082 let result = eval ( data . join ( "" ) ) ;
83+ console . log ( eval ( data . join ( "" ) ) )
8184 displayResult ( data , result ) ;
8285 divideByZero ( screen , result ) ;
8386 } catch ( e ) {
@@ -133,7 +136,7 @@ function canUserAddDot() {
133136 }
134137 data . push ( "." ) ;
135138 }
136- screen . innerText = data . join ( "" ) ;
139+ screen . innerText = data . join ( " " ) ;
137140}
138141
139142function deleteEverythingFromScreen ( ) {
@@ -144,11 +147,13 @@ function deleteEverythingFromScreen() {
144147
145148function toggleSign ( ) {
146149 let currentValue = data [ data . length - 1 ] ;
150+ console . log ( currentValue )
147151 if ( currentValue === undefined ) return ;
148152 let toggledValue = - currentValue ;
149- screen . innerText = toggledValue ; // Update the screen
153+ // screen.innerText = toggledValue; // Update the screen
150154 // Update the value in the data array
151155 data [ data . length - 1 ] = toggledValue ;
156+ screen . innerText = data . join ( "" ) ;
152157 console . log ( data ) ;
153158}
154159
0 commit comments