diff --git a/src/logic/operate.js b/src/logic/operate.js index 0274e3a74..e9fa87c48 100644 --- a/src/logic/operate.js +++ b/src/logic/operate.js @@ -2,7 +2,9 @@ import Big from "big.js"; export default function operate(numberOne, numberTwo, operation) { const one = Big(numberOne || "0"); - const two = Big(numberTwo || (operation === "÷" || operation === 'x' ? "1": "0")); //If dividing or multiplying, then 1 maintains current value in cases of null + const two = Big( + numberTwo || (operation === "÷" || operation === "x" ? "1" : "0"), + ); //If dividing or multiplying, then 1 maintains current value in cases of null if (operation === "+") { return one.plus(two).toString(); } @@ -13,7 +15,8 @@ export default function operate(numberOne, numberTwo, operation) { return one.times(two).toString(); } if (operation === "÷") { - if (two === "0") { + // ISSUE #77 & 105 - Error while dividing by zero + if (two.eq(0)) { alert("Divide by 0 error"); return "0"; } else {