From fcadc3cc9a71e9f84906124b4c7582b46aae3df0 Mon Sep 17 00:00:00 2001 From: lolabird Date: Tue, 26 Dec 2023 22:44:28 -0700 Subject: [PATCH] Fix issue of pressing = without pending operation --- script.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index 611eeb1..4dd1e09 100644 --- a/script.js +++ b/script.js @@ -56,13 +56,16 @@ function Calculator(str) { op = parts[1]; b = +parts[2]; + + if (a && !b) { + return a; + } if (isNaN(a) || isNaN(b)) { return NaN; } if (!this.methods[op]) { return "Operation not supported." } - return this.methods[op](a, b); }; } \ No newline at end of file