Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions projects/tip-calculator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ const totalSpan = document.getElementById("total");
function calculateTotal() {
const billValue = billInput.value;
const tipValue = tipInput.value;
if(tipValue<=0||billValue<=0){
alert("bill value or tip value cannot be less than equal to zero);
}else{
const totalValue = billValue * (1 + tipValue / 100);
totalSpan.innerText = totalValue.toFixed(2);
}
}

btnEl.addEventListener("click", calculateTotal);