@@ -102,17 +102,18 @@ document.addEventListener("DOMContentLoaded", () => {
102102 } ) ;
103103 } ) ;
104104 // forEach ends & functions creations begins
105- function convertToPercentage ( button : string ) {
105+ function convertToPercentage ( button : string ) : void {
106106 if ( button === "%" ) {
107107 currentExpression = Number ( data . join ( "" ) ) ;
108108 currentExpression = currentExpression / 100 ;
109109 data = [ currentExpression ] ;
110110 console . log ( data ) ;
111111 screenElement . innerText = String ( currentExpression ) ;
112112 }
113+ console . log ( "convertToPercentage(" )
113114 }
114115
115- function deteLastEntry ( button : string ) {
116+ function deteLastEntry ( button : string ) : void {
116117 if ( button === "DE" ) {
117118 let newArray = data . slice ( ZERO , - 1 ) ;
118119 screenElement . innerText = newArray . join ( "" ) ;
@@ -123,7 +124,7 @@ document.addEventListener("DOMContentLoaded", () => {
123124 }
124125 }
125126
126- function canUserAddDot ( button : string ) {
127+ function canUserAddDot ( button : string ) : void {
127128 if ( button === "." ) {
128129 var dotAllowed = true ;
129130 for ( var i = data . length - 1 ; i >= ZERO ; i -- ) {
@@ -146,64 +147,19 @@ document.addEventListener("DOMContentLoaded", () => {
146147 }
147148 }
148149
149- function deleteEverythingFromScreen ( button : string ) {
150+ function deleteEverythingFromScreen ( button : string ) : void {
150151 if ( button === "AC" ) {
151152 screenElement . innerText = "" ;
152153 data = [ ] ;
153154 screenElement . innerText = String ( ZERO ) ;
154155 }
155156 }
156157
157- // function toggleSign(button) {
158- // if (button === "minus") {
159- // console.log(data[0])
160- // currentExpression = data.join("");
161- // console.log(currentExpression)
162- // let reversedExpression = currentExpression.split("").join("");
163- // console.log(reversedExpression)
164- // let match = reversedExpression.match(/(\d+(\.\d+)?)|(\D+)/); // Match a number or non-digit
165-
166- // if (match) {
167- // let start = currentExpression.length - match[ZERO].length;
168- // let end = currentExpression.length;
169- // let currentValue = Number(match[ZERO]);
170-
171- // if (!isNaN(currentValue)) {
172- // currentValue = -currentValue;
173- // data = data
174- // .slice(ZERO, start)
175- // .concat(currentValue.toString().split(""), data.slice(end));
176- // screenElement.innerText = data.join("");
177- // }
178- // }
179- // }
180- // }
181-
182- // The unshift() method of Array instances adds the specified elements to the beginning
183- // of an array and returns the new length of the array.
184-
185- // The shift() method of Array instances removes the first element from an array and returns
186- // that removed element. This method changes the length of the array.
158+
187159
188160 minus . addEventListener ( "click" , ( ) => toggleSign ( "minus" ) ) ;
189161
190- // function toggleSign(button) {
191- // let value = Number(data.join(""))
192- // if (button === "minus") {
193- // if (value > 0) {
194- // value = -value
195- // console.log(value);
196- // screenElement.innerText = value;
197- // } if (value < 0) {
198- // console.log("smaller than zero")
199- // value = value * -1
200- // console.log(value)
201- // screenElement.innerText = value;
202- // }
203- // // screenElement.innerText = value;
204- // data = [value]
205- // }
206- // }
162+
207163
208164 function toggleSign ( button : string ) : void {
209165 let value = Number ( data . join ( "" ) ) ;
@@ -239,13 +195,15 @@ document.addEventListener("DOMContentLoaded", () => {
239195 }
240196 screenElement . innerText = data . join ( "" ) ;
241197 }
198+ console . log ( "insertOpeningParenthesis" )
242199 }
243200
244201 function insertClosingParenthesis ( button : string ) : void {
245202 if ( button === ")" ) {
246203 data . push ( ")" ) ;
247204 screenElement . innerText = data . join ( "" ) ;
248205 }
206+ console . log ( "insertClosingParenthesis" )
249207 }
250208
251209 function handlingZeroFollowedByAdecimal ( button : string ) : void {
@@ -281,7 +239,7 @@ document.addEventListener("DOMContentLoaded", () => {
281239 }
282240 }
283241
284- function userClicksOnEqualButton ( button : string ) {
242+ function userClicksOnEqualButton ( button : string ) : void {
285243 if ( button === "=" ) {
286244 try {
287245 const replacedArray = data . map ( ( item ) =>
0 commit comments