From 013623226db6af5c6e497311ceccfe38845367a4 Mon Sep 17 00:00:00 2001 From: lolabird Date: Thu, 28 Dec 2023 09:00:35 -0700 Subject: [PATCH] Get minus sign to act as both a sign change toggler and operator depending on on the context --- script.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/script.js b/script.js index da792e5..1cf6a6c 100644 --- a/script.js +++ b/script.js @@ -43,6 +43,13 @@ function displayEval() { function displayOperator() { let result = 0 + let operator = this.textContent; + + if (operator == "-" && (isNaN(mainScreen.textContent) || mainScreen.textContent == "0")) { + console.log("Entering changeSign"); + changeSign(); + return; + } if (topScreen.textContent == "" || !inOps) { topScreen.textContent = mainScreen.textContent + " " + this.textContent + " ";