Intern — Middle
Creating a function to calculate age using Function Expression
livecode
Task condition
Implement the getAge() function that takes a birth date as an argument and returns the calculated age. The function should be declared using a Function Expression. Example usage:
const calculateAge = function(birthDate) {
// implementation
};
const age = calculateAge(new Date('1990-05-15'));
console.log(age); // outputs the current age
The function should work correctly with dates in both the past and the future, taking leap years into account.