From 483bd6164f86cc27e3fee13acd0480585f8adf6f Mon Sep 17 00:00:00 2001 From: niveditasargar Date: Sat, 2 Aug 2025 14:03:15 +0530 Subject: [PATCH] Added Clear button to Age Calculator --- projects/age-calculator/index.html | 3 +++ projects/age-calculator/index.js | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/projects/age-calculator/index.html b/projects/age-calculator/index.html index 7ef5c27..efa3c2f 100644 --- a/projects/age-calculator/index.html +++ b/projects/age-calculator/index.html @@ -14,6 +14,9 @@

Age Calculator

+ +

+

Your age is 21 years old

diff --git a/projects/age-calculator/index.js b/projects/age-calculator/index.js index b2888ee..40eba98 100644 --- a/projects/age-calculator/index.js +++ b/projects/age-calculator/index.js @@ -29,3 +29,11 @@ function getAge(birthdayValue) { } btnEl.addEventListener("click", calculateAge); + +// ✅ New: Clear button logic +const clearBtn = document.getElementById("clearBtn"); + +clearBtn.addEventListener("click", function () { + birthdayEl.value = ""; + resultEl.innerText = ""; +});