diff --git a/script2.js b/script2.js index 288064c..7fec622 100644 --- a/script2.js +++ b/script2.js @@ -52,6 +52,8 @@ function displayOperator() { topScreen.textContent += mainScreen.textContent; result = calc.calculate(topScreen.textContent); + + topScreen.textContent = result + " " + this.textContent + " "; } mainScreen.textContent = result; @@ -60,11 +62,16 @@ function displayOperator() { function displayNum() { - if (mainScreen.textContent == "0") { + if (mainScreen.textContent == "0" || inOps) { mainScreen.textContent = this.textContent; + inOps = false; } else { mainScreen.textContent += this.textContent; } + + if (isNaN(topScreen.textContent) && isNaN(topScreen.textContent.charAt(-1))) { + topScreen.textContent += this.textContent; + } }