Age Calculator body { font-family: Arial, sans-serif; } .container { width: 300px; margin: 50px auto; text-align: center; } input, button { margin: 10px 0; padding: 5px; } #result { margin-top: 20px; font-weight: bold; } Age Calculator Calculate Age function calculateAge() { const birthDate = new Date(document.getElementById('birthDate').value); const today = new Date(); let years = today.getFullYear() - birthDate.getFullYear(); let months = today.getMonth() - birthDate.getMonth(); let days = today.getDate() - birthDate.getDate(); if (days < 0) { months--; const lastDayOfPreviousMonth = new Date(today.getFullYear(), today.getMonth(), 0).getDate(); days = lastDayOfPreviousMonth - birthDate.getDate() + today.getDate(); } if (months < 0) { years--; months += 12; } document.getElementById('result').textContent = `You are ${years} years, ${months} months, and ${days} days old.`; }