File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments