Skip to content

Commit 56024bb

Browse files
committed
feat(JS) commented out first if statement in try use ternary operator in else statement
1 parent 08ba4ec commit 56024bb

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,17 @@ btns.forEach((btn) => {
7878
try {
7979
const replacedArray = data.map((item) => (item === "x" ? "*" : item === "÷" ? "/" : item));
8080
// Check if the expression involves 0/0
81+
// if (areYouDivindingByZero(replacedArray)) {
82+
// screen.innerText = "You cannot divide by zero. Press AC";
83+
// }
84+
8185
if (areYouDividingdZeroByZero(replacedArray)) {
82-
screen.innerText = "0/0 is an invalid format used. Press AC";
83-
} if (areYouDivindingByZero(replacedArray)) {
84-
screen.innerText = "You cannot divide by zero. Press AC";
85-
// debugger
86-
} else {
86+
screen.innerText = "0÷0 is an invalid format. Press AC";
87+
} else {
8788
let result = eval(replacedArray.join(""));
8889
console.log(result)
8990
displayResult(replacedArray, result);
90-
screen.innerText = result
91+
screen.innerText = result === Infinity ? "You cannot divide by zero. Press AC" : result
9192
// divideByZero(screen, result);
9293
data = [];
9394
data.push(result);

0 commit comments

Comments
 (0)