Skip to content

Commit e4fbfc8

Browse files
committed
beautify js file
1 parent 8d5827c commit e4fbfc8

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

VAT Calculator/script.js

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,48 @@ const incAmount = document.querySelector("#inc-amount");
55
const calcBtn = document.querySelector("#calc-btn")
66
const resetBtn = document.querySelector("#reset-btn")
77

8-
function VATInclusiveAmount(price, rate){
9-
let vatAddedPrice = Number((price * (rate/100)));
10-
vatAdded.value = vatAddedPrice.toFixed(2);
11-
let totalAmount = Number(price) + vatAddedPrice ;
12-
return totalAmount;
8+
function VATInclusiveAmount(price, rate) {
9+
let vatAddedPrice = Number((price * (rate / 100)));
10+
vatAdded.value = vatAddedPrice.toFixed(2);
11+
let totalAmount = Number(price) + vatAddedPrice;
12+
return totalAmount;
1313
}
1414

15-
calcBtn.addEventListener('click', function(){
16-
if(netPrice.value === "" || isNaN(netPrice.value)){
17-
// show red border
18-
netPrice.style.border = "1px solid red";
19-
20-
// removing red border after 1.5s
21-
setTimeout(function(){
22-
netPrice.style.border = "1px solid transparent";
23-
}, 1500);
24-
25-
netPrice.value = "";
26-
}
27-
28-
if(vatRate.value === "" || isNaN(vatRate.value)){
29-
// show red border
30-
vatRate.style.border = "1px solid red";
31-
32-
// removing red border after 1.5s
33-
setTimeout(function(){
34-
vatRate.style.border = "1px solid transparent";
35-
}, 1500);
36-
37-
// remove wrong value
38-
vatRate.value = "";
39-
}
40-
41-
let finalAmount = VATInclusiveAmount((netPrice.value), (vatRate.value));
42-
incAmount.value = finalAmount;
43-
15+
calcBtn.addEventListener('click', function() {
16+
if (netPrice.value === "" || isNaN(netPrice.value)) {
17+
// show red border
18+
netPrice.style.border = "1px solid red";
19+
20+
// removing red border after 1.5s
21+
setTimeout(function() {
22+
netPrice.style.border = "1px solid transparent";
23+
}, 1500);
24+
25+
netPrice.value = "";
26+
}
27+
28+
if (vatRate.value === "" || isNaN(vatRate.value)) {
29+
// show red border
30+
vatRate.style.border = "1px solid red";
31+
32+
// removing red border after 1.5s
33+
setTimeout(function() {
34+
vatRate.style.border = "1px solid transparent";
35+
}, 1500);
36+
37+
// remove wrong value
38+
vatRate.value = "";
39+
}
40+
41+
let finalAmount = VATInclusiveAmount((netPrice.value), (vatRate.value));
42+
incAmount.value = finalAmount;
43+
4444

4545
})
4646

47-
resetBtn.addEventListener("click", function(){
48-
netPrice.value="";
49-
vatRate.value="";
50-
vatAdded.value = "";
51-
incAmount.value="";
52-
})
47+
resetBtn.addEventListener("click", function() {
48+
netPrice.value = "";
49+
vatRate.value = "";
50+
vatAdded.value = "";
51+
incAmount.value = "";
52+
})

0 commit comments

Comments
 (0)