Skip to content

Commit 8786e90

Browse files
committed
feat(JS): delete commented out functions
1 parent a9bcbe1 commit 8786e90

File tree

1 file changed

+2
-44
lines changed

1 file changed

+2
-44
lines changed

index.js

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,14 @@ function toggleSign(button) {
128128
let currentExpression = data.join("");
129129
let reversedExpression = currentExpression.split("").join("");
130130
let match = reversedExpression.match(/(\d+(\.\d+)?)|(\D+)/); // Match a number or non-digit
131-
// debugger
131+
132132

133133
if (match) {
134134
let start = currentExpression.length - match[ZERO].length;
135135
let end = currentExpression.length;
136136
let currentValue = Number(match[ZERO]);
137137

138138
if (!isNaN(currentValue)) {
139-
// If it's a number, toggle its sign
140139
currentValue = -currentValue;
141140
data = data
142141
.slice(ZERO, start)
@@ -207,51 +206,21 @@ function userClicksOnEqualButton(button) {
207206
if (button === "=") {
208207
try {
209208
const replacedArray = data.map((item) =>
210-
item === "x" ? "*" : item === "÷" ? "/" : item
211-
);
212-
213-
// console.log(historyEntries)
214-
// Check if the expression involves 0/0
215-
// if (areYouDivindingByZero(replacedArray)) {
216-
// screen.innerText = "You cannot divide by zero. Press AC";
217-
// }
218-
209+
item === "x" ? "*" : item === "÷" ? "/" : item);
219210
if (areYouDividingdZeroByZero(replacedArray)) {
220211
screen.innerText = "0÷0 is an invalid format. Press AC";
221212
} else {
222213
let result = eval(replacedArray.join(""));
223214
let historyEntries = [[...replacedArray, "=", result]];
224-
// let computationHistory = replacedArray.slice();
225-
226-
console.log(historyEntries)
227-
228215
replacedArray.splice(replacedArray.length, 0, "=", result);
229-
// history.push(replacedArray.join(""));
230-
231-
232-
233216
displayResult(replacedArray, result);
234217
screen.innerText = !Number.isFinite(result) ? "You cannot divide by zero. Press AC" : result;
235-
// divideByZero(screen, result);
236218
data = [];
237219
data.push(result);
238-
239220
createHistoryList(historyEntries, historyElement, history);
240-
241221
togglesClearHistoryButton(historyElement, clearHistoryBtn);
242-
243-
// debugger
244-
245-
246-
247-
248-
249-
250-
251-
252222
}
253223
} catch (e) {
254-
// debugger
255224
screen.innerText = `${e.name} press AC`;
256225
}
257226
}
@@ -296,13 +265,6 @@ function createHistoryList(array, element, history) {
296265

297266
});
298267
}
299-
300-
// function togglesClearHistoryButton(element, btn) {
301-
// const hasChildElements = element.childElementCount > 0;
302-
// btn.classList.toggle("display", hasChildElements);
303-
// }
304-
305-
///
306268
clearHistoryBtn.addEventListener("click", () => {
307269
historyElement.innerHTML = "";
308270
togglesClearHistoryButton(historyElement, clearHistoryBtn);
@@ -311,8 +273,4 @@ clearHistoryBtn.addEventListener("click", () => {
311273
function togglesClearHistoryButton(element, btn) {
312274
btn.classList.toggle("display", element.childElementCount > 0);
313275
}
314-
315-
316-
317-
318276
// functions creations ends

0 commit comments

Comments
 (0)