Skip to content

Commit edcedbe

Browse files
committed
Limit tip to 20
1 parent 9178903 commit edcedbe

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

projects/tip-calculator/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@ const totalSpan = document.getElementById("total");
66
function calculateTotal() {
77
const billValue = billInput.value;
88
const tipValue = tipInput.value;
9-
const totalValue = billValue * (1 + tipValue / 100);
10-
totalSpan.innerText = totalValue.toFixed(2);
9+
if(tipValue<20){
10+
const totalValue = billValue * (1 + tipValue / 100);
11+
totalSpan.innerText = totalValue.toFixed(2);
12+
}
13+
else{
14+
totalValue = String("The tip is abusive");
15+
totalSpan.innerText= totalValue;
16+
}
17+
18+
1119
}
1220

1321
btnEl.addEventListener("click", calculateTotal);

0 commit comments

Comments
 (0)