Fix issue of pressing = without pending operation
This commit is contained in:
parent
322a14b9f8
commit
fcadc3cc9a
1 changed files with 4 additions and 1 deletions
|
|
@ -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);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue