@@ -6,6 +6,7 @@ const slidingPart = document.querySelector(".sliding-part");
66const computationHistoryParent = document . querySelector ( ".computation-history-parent" ) ;
77const operators = document . querySelectorAll ( "[data-operator]" ) ;
88const clearHistoryBtn = document . querySelector ( ".clear-history-btn" ) ;
9+ let currentExpression
910
1011clearHistoryBtn . addEventListener ( "click" , ( ) => {
1112 historyElement . innerHTML = "" ;
@@ -83,7 +84,10 @@ btns.forEach((btn) => {
8384// forEach ends & functions creations begins
8485function convertToPercentage ( button ) {
8586 if ( button === "%" ) {
86- screen . innerText = screen . innerText / 100 ;
87+ currentExpression = data . join ( '' ) ;
88+ currentExpression = currentExpression / 100 ;
89+ data = [ currentExpression ] ;
90+ screen . innerText = currentExpression ;
8791 }
8892}
8993
@@ -131,8 +135,11 @@ function deleteEverythingFromScreen(button) {
131135
132136function toggleSign ( button ) {
133137 if ( button === "minus" ) {
134- let currentExpression = data . join ( "" ) ;
138+ console . log ( data )
139+ currentExpression = data . join ( "" ) ;
140+ console . log ( currentExpression )
135141 let reversedExpression = currentExpression . split ( "" ) . join ( "" ) ;
142+ console . log ( reversedExpression )
136143 let match = reversedExpression . match ( / ( \d + ( \. \d + ) ? ) | ( \D + ) / ) ; // Match a number or non-digit
137144
138145 if ( match ) {
0 commit comments