mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2024-12-25 22:10:43 -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 result = operate(first, second, ops.operator);
|
||||
// result = Math.round(result * (10^3)/(10^3));
|
||||
if (result === "error") {
|
||||
ops.clear();
|
||||
return;
|
||||
}
|
||||
result = result.toPrecision(3);
|
||||
updateDisplay(result);
|
||||
ops.firstNum = result;
|
||||
|
|
Loading…
Reference in a new issue