-
Notifications
You must be signed in to change notification settings - Fork 0
/
_statement.js
34 lines (29 loc) · 853 Bytes
/
_statement.js
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
26
27
28
29
30
31
32
33
34
var powFlag = false;
function addToCalculator(value) {
document.getElementById("displayResult").value += value;
if (powFlag) {
var numbers = document.getElementById("displayResult").value.split("^");
document.getElementById("displayResult").value = Math.pow(
numbers[0],
numbers[1]
);
powFlag = false;
}
}
function finilize() {
document.getElementById("displayResult").value = eval(
document.getElementById("displayResult").value
);
}
function reset() {
document.getElementById("displayResult").value = "";
}
function mathCalculator(mathFunc) {
if (mathFunc == "pow") {
powFlag = true;
document.getElementById("displayResult").value += "^";
} else {
var val = document.getElementById("displayResult").value;
document.getElementById("displayResult").value = Math[mathFunc](val);
}
}