| 20 | |
| 21 | |
| 22 | function evaluate(){ |
| 23 | let exp = calculationText.innerText.split(/[+\-\×\÷\%]/,2) |
| 24 | let num1 =exp[0] |
| 25 | let num2 = exp[1] |
| 26 | switch(calculationText.innerText[num1.length]){ |
| 27 | case '+': operand = add;break |
| 28 | case '-': operand = subtract;break |
| 29 | case '×': operand = mult; break |
| 30 | case '÷': operand = divide; break |
| 31 | case '%': operand = percent; break |
| 32 | } |
| 33 | result = operand(parseFloat(num1),parseFloat(num2)) |
| 34 | updateResult(result) |
| 35 | calculated = true |
| 36 | } |
| 37 | const modeAdd = 0; |
| 38 | const modeRem = 1; |
| 39 | function updateCalculation(character, mode){ |