-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtip.js
43 lines (26 loc) · 901 Bytes
/
tip.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
40
41
42
43
let bill = 0;
let rating = 0;
let sharingBill = 0;
let result;
document.getElementById("calculate").onclick = function() {
tipCalculator();
console.log('here');
}
function tipCalculator(){
let bill = document.getElementById("bill").value;
let rating = document.getElementById("rating").value;
let sharingBill = document.getElementById("sharing-bill").value;
if (sharingBill === null || sharingBill <= 1)
{
sharingBill = 1;
document.getElementById("each").style.display = "none";
}
else {
document.getElementById("each").style.display = "block";
}
let total = (bill * rating) / sharingBill;
result = Math.round(total * 1000)/1000;
console.log(result);
// document.getElementsByClassName('total').style.display ;
document.getElementById("tip").innerHTML = result;
}