-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
35 lines (32 loc) · 970 Bytes
/
main.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
35
const result = document.getElementById("resultArea");
// const Toggle = document.getElementById("toggle");
const buttons = Array.from(document.getElementsByClassName("button"));
// const userTheme = localStorage.getItem("theme");
buttons.map((button) => {
button.addEventListener("click", (e) => {
switch (e.target.innerText) {
case "RESET":
result.innerText = "";
break;
case "DEL":
if (result.innerText) {
result.innerText = result.innerText.slice(0, -1);
}
break;
case "=":
try {
result.innerText = eval(result.innerText);
} catch {
result.innerText = "Error!";
}
break;
default:
result.innerText += e.target.innerText;
}
});
});
// Toggle.addEventListener("click", () => {
// document.body.classList.toggle("dark");
// Toggle.classList.toggle("justify-start");
// Toggle.classList.toggle("justify-end");
// });