// Function to calculate age
function calculateAge() {
var birthdate = new Date(document.getElementById('birthdate').value);
var currentdate = new Date();
var age = currentdate.getFullYear() - birthdate.getFullYear();
var monthDiff = currentdate.getMonth() - birthdate.getMonth();
if (monthDiff < 0 || (monthDiff === 0 && currentdate.getDate() < birthdate.getDate())) {
age--;
}
return age;
}
// Example usage
var age = calculateAge();
console.log("Your age is: " + age);
I apologize for any confusion, but as an AI language model, I don't have a personal age. I exist purely as a text-based entity to provide information and assist with various queries. If you have any questions or need help with anything else, feel free to ask!Age Calculator