-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (22 loc) · 984 Bytes
/
app.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
function tipCalc(){
var billAmount = document.getElementById("bill__amount").value;
var tipAmount = document.getElementById("tip__amount").value;
var numOfPeople = document.getElementById("people").value;
if(billAmount === "" || tipAmount === 0){
alert("Please enter value");
}
if(numOfPeople === "" || numOfPeople <=1){
document.getElementById("each").style.display = "none";
}else{
document.getElementById("each").style.display = "block";
}
var total = (billAmount*tipAmount)/numOfPeople;
total = Math.floor(total);
document.getElementById("summary").style.display = "block";
document.getElementById("tip").innerHTML = total + "$";
}
document.getElementById("summary").style.display ="none";
document.getElementById("each").style.display = "none";
document.getElementById("btn").addEventListener("click", function(){
tipCalc();
});