Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This is the solution to the Codewars Kata: How Old Will I be in 2099
function calculateAge(birthDate, otherDate) {
var age = otherDate - birthDate;
if(age === 1) {
return 'You are ' + age + ' year old.';
} else if(age > 1) {
return 'You are ' + age + ' years old.';
} else if (age < -1) {
return 'You will be born in ' + Math.abs(age) + ' years.';
} else if (age === -1) {
return 'You will be born in ' + Math.abs(age) + ' year.';
} else {
return 'You were born this very year!';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.