-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
33 lines (30 loc) · 813 Bytes
/
script.js
File metadata and controls
33 lines (30 loc) · 813 Bytes
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
enter = (val) => {
document.getElementById("InputBox").value += val;
};
solve = () => {
let x = document.getElementById("InputBox").value;
if (x === "") alert("Please enter some values ");
else {
try {
if (x.includes("%", x.length - 1) && x.length > 1) {
x = x.slice(0, -1);
let a = eval(x);
a = a / 100;
document.getElementById("InputBox").value = a;
return;
}
let y = eval(x);
document.getElementById("InputBox").value = y;
} catch (error) {
alert("Your expression is wrong ");
}
}
};
back = () => {
document.getElementById("InputBox").value = document
.getElementById("InputBox")
.value.slice(0, -1);
};
cls = () => {
document.getElementById("InputBox").value = " ";
};