Fix mainScreen behavior

This commit is contained in:
lolabird 2023-12-27 19:30:11 -07:00
commit f63ad42a36

View file

@ -52,6 +52,8 @@ function displayOperator() {
topScreen.textContent += mainScreen.textContent; topScreen.textContent += mainScreen.textContent;
result = calc.calculate(topScreen.textContent); result = calc.calculate(topScreen.textContent);
topScreen.textContent = result + " " + this.textContent + " ";
} }
mainScreen.textContent = result; mainScreen.textContent = result;
@ -60,11 +62,16 @@ function displayOperator() {
function displayNum() { function displayNum() {
if (mainScreen.textContent == "0") { if (mainScreen.textContent == "0" || inOps) {
mainScreen.textContent = this.textContent; mainScreen.textContent = this.textContent;
inOps = false;
} else { } else {
mainScreen.textContent += this.textContent; mainScreen.textContent += this.textContent;
} }
if (isNaN(topScreen.textContent) && isNaN(topScreen.textContent.charAt(-1))) {
topScreen.textContent += this.textContent;
}
} }