Skip to content

Commit

Permalink
Fixed an error where pressing enter resulted in zero
Browse files Browse the repository at this point in the history
  • Loading branch information
jithin-rajesh committed Dec 15, 2024
1 parent 363bd7e commit 9c09ca5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,13 @@ function handleEqualsClick() {
if (!oldNum || !currentNum) return;
let result = operate(oldNum, currentNum, currentOperator);
answerText.textContent = exponential(result);
currentNum = result.toString();
oldNum = "";
currentOperator = "";
operatorDisplay.textContent = "";

if (result !== "null") {
currentNum = result.toString();
oldNum = "";
currentOperator = "";
operatorDisplay.textContent = "";
}
}

function handleClearClick() {
Expand Down

0 comments on commit 9c09ca5

Please sign in to comment.