diff --git a/projects/tip-calculator/index.js b/projects/tip-calculator/index.js index 98cb079..35facbb 100644 --- a/projects/tip-calculator/index.js +++ b/projects/tip-calculator/index.js @@ -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);