MCPcopy Create free account
hub / github.com/AyushSaini00/60minuteJavaScript / compute

Method compute

Calculator/app.js:35–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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;

Callers 2

chooseOperationMethod · 0.95
app.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected