commit
f983992700
1 changed files with 2 additions and 2 deletions
|
@ -10,14 +10,14 @@ function Calculator() {
|
||||||
let split = str.split(' '),
|
let split = str.split(' '),
|
||||||
a = +split[0],
|
a = +split[0],
|
||||||
op = split[1],
|
op = split[1],
|
||||||
b = +split[2]
|
b = +split[2];
|
||||||
|
|
||||||
if (!this.methods[op] || isNaN(a) || isNaN(b)) {
|
if (!this.methods[op] || isNaN(a) || isNaN(b)) {
|
||||||
return NaN;
|
return NaN;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.methods[op](a, b);
|
return this.methods[op](a, b);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.addMethod = function(name, func) {
|
this.addMethod = function(name, func) {
|
||||||
this.methods[name] = func;
|
this.methods[name] = func;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue