()
| 33 | } |
| 34 | |
| 35 | compute(){ |
| 36 | let computation; |
| 37 | let prev = parseFloat(this.previousOperant); |
| 38 | let current = parseFloat(this.currentOperant); |
| 39 | |
| 40 | if(isNaN(prev) || isNaN(current)) |
| 41 | return; |
| 42 | switch(this.operation){ |
| 43 | case '+' : |
| 44 | computation = prev + current; |
| 45 | break; |
| 46 | case '−' : |
| 47 | computation = prev - current; |
| 48 | break; |
| 49 | case '×' : |
| 50 | computation = prev * current; |
| 51 | break; |
| 52 | case '÷' : |
| 53 | computation = prev / current; |
| 54 | break; |
| 55 | default: |
| 56 | return; |
| 57 | } |
| 58 | |
| 59 | this.currentOperant = computation; |
| 60 | this.operation = undefined; |
| 61 | this.previousOperant = ''; |
| 62 | } |
| 63 | |
| 64 | updateDisplay(){ |
| 65 | this.resultElement.innerText = this.currentOperant; |
no outgoing calls
no test coverage detected