fix: add error handling for division

This commit is contained in:
Mike 2023-10-12 17:32:20 -04:00
parent 7248f314e1
commit 93a933af92

View file

@ -84,6 +84,10 @@ function handleOperation() {
let second = Number(ops.secondNum); let second = Number(ops.secondNum);
let result = operate(first, second, ops.operator); let result = operate(first, second, ops.operator);
// result = Math.round(result * (10^3)/(10^3)); // result = Math.round(result * (10^3)/(10^3));
if (result === "error") {
ops.clear();
return;
}
result = result.toPrecision(3); result = result.toPrecision(3);
updateDisplay(result); updateDisplay(result);
ops.firstNum = result; ops.firstNum = result;