-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
29 lines (28 loc) · 1.13 KB
/
script.js
File metadata and controls
29 lines (28 loc) · 1.13 KB
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
function togglecolormode() {
var background = document.body;
background.classList.toggle("dark-mode");
}
function runupdatebykeyboard(event) {
if (event.key == "Enter") {
update();
}
}
function update() {
let topay = parseInt(document.getElementById("topay").value);
let percent = parseInt(document.getElementById("percent").value);
let extra = document.getElementById("extra").value;
let calculate_extra;
if (extra == "korting") {
calculate_extra = -1;
} else if (extra == "verhoging") {
calculate_extra = 1;
} else {
alert("Fout! voer verhoging of korting in.");
}
let amount = parseInt(document.getElementById("amount").value);
let result = (topay + ((topay * (percent / 100)) * calculate_extra)) * amount;
let noextra = topay * amount;
document.getElementById("result").innerHTML = result;
document.getElementById("resultdata").innerHTML = "moest betalen voor een stuk: " + topay + "<br>procent: " + percent + "<br>korting of verhoging: " + extra + "<br>aantal: " + amount + "<br>moest betalen zonder korting/verhoging: " + noextra + "<br>aantal bespaard/meer betaald: " + Math.abs(result - noextra);
}
togglecolormode();