Define a function called ageCalculator. This function should take three parameters:
name: a string representing someone’s name
yearOfBirth: a number representing their year of birth
currentYear: a number representing the current year
The ageCalculator function should return a string stating how old the person is. For example, if you called ageCalculator("Suzie", 1983, 2015);, the return value should be as follows:
"Suzie is 32 years old.";
My code:
const ageCalculator = {
name: "James",
yearOfBirth: 1992,
currentYear: 2024
};
const age = ageCalculator.currentYear - ageCalculator.yearOfBirth;
console.log(ageCalculator.name + " is " + age + " years old.");