-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calculator.js
39 lines (34 loc) · 967 Bytes
/
Calculator.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
36
37
38
39
function calcNumber(result) {
document.querySelector('.area').value += result;
}
function percentage(result) {
var result1 = String(result);
if (result1.includes("%")) {
var a, b, percent;
var splitWord = [];
a = Number(splitWord[0]);
b = Number(splitWord[1]);
percent = (a / 100 * b);
document.querySelector('.area').value = percent;
}
}
function makeNegative(result) {
if (result.chartAt(0) == '_') {
document.querySelector('.area').value = result.replace('-', '');
}
else {
document.querySelector('.area').value = '-' + result;
}
}
const body = document.querySelector("body");
const modeToggle = document.querySelector(".dark-light");
modeToggle.addEventListener("click", () => {
modeToggle.classList.toggle("active");
body.classList.toggle("dark");
if (!body.classList.contains("dark")) {
localStorage.setItem("mode", "light-mode");
}
else {
localStorage.setItem("mode", "dark-mode");
}
});