Fix issue of pressing = without pending operation

This commit is contained in:
lolabird 2023-12-26 22:44:28 -07:00
commit fcadc3cc9a

View file

@ -56,13 +56,16 @@ function Calculator(str) {
op = parts[1]; op = parts[1];
b = +parts[2]; b = +parts[2];
if (a && !b) {
return a;
}
if (isNaN(a) || isNaN(b)) { if (isNaN(a) || isNaN(b)) {
return NaN; return NaN;
} }
if (!this.methods[op]) { if (!this.methods[op]) {
return "Operation not supported." return "Operation not supported."
} }
return this.methods[op](a, b); return this.methods[op](a, b);
}; };
} }