mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2024-12-26 22:30:44 -05:00
fix: add error handling for division
This commit is contained in:
parent
7248f314e1
commit
93a933af92
1 changed files with 4 additions and 0 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue