-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddOperation.txt
25 lines (23 loc) · 950 Bytes
/
addOperation.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
He pushed her roughly out of the way.
addOperation(value){
if (!this.isOperation(value)) {
if (!isNaN(this.getLastOperation())) {
let lastNumber = this._operations.pop();
let currentNumber = parseInt(lastNumber+value);
this._operations.push(currentNumber);
this.displayResult = currentNumber;
} else {
let currentNumber = parseInt(value);
this._operations.push(currentNumber);
this.displayResult = currentNumber;
}
} else {
if (this._operations.length >= 3){
this.calc();
} else if(this.isOperation(this.getLastOperation())) {
this.setOperator(value);
} else {
this._operations.push(value);
}
}
}