From 4f5ea78cf0c693c65a373c9f699d3210289bbf02 Mon Sep 17 00:00:00 2001 From: mukilan143 Date: Fri, 18 Apr 2025 16:02:11 +0530 Subject: [PATCH] small issue in age calc fixed --- projects/age-calculator/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects/age-calculator/index.js b/projects/age-calculator/index.js index b2888ee..816032b 100644 --- a/projects/age-calculator/index.js +++ b/projects/age-calculator/index.js @@ -8,6 +8,10 @@ function calculateAge() { alert("Please enter your birthday"); } else { const age = getAge(birthdayValue); + if (age < 0) { + alert("please select a valid date"); + return;//if age is less than 0 then alert the user to select a valid date + } resultEl.innerText = `Your age is ${age} ${age > 1 ? "years" : "year"} old`; } }