Codecademy howOld() made me realise how much i need to rethink my thinking, need some guidance please

This is what i was suppose to do:
Write a function, howOld(), that has two number parameters, age and year, and returns how old someone who is currently that age was (or will be) during that year. Handle three different cases:

  1. If the year is in the future, you should return a string in the following format:
    ‘You will be [calculated age] in the year [year passed in]’

  2. If the year is before they were born, you should return a string in the following format:
    ‘The year [year passed in] was [calculated number of years] years before you were born’

  3. If the year is in the past but not before the person was born, you should return a string in the following format:
    ‘You were [calculated age] in the year [year passed in]’

my function works and passes the task but when i looked at the hint to compare i felt really stupid.
The hint:
“You might find these two variables helpful:
const yearDifference = year – theCurrentYear
const newAge = age + yearDifference
Once you have newAge, you’ll be able to handle the three difference cases.
If the newAge is less than 0, this means the year provided was before the person was born. If the newAge is greater than their current age, this means the year passed in is in the future. Otherwise, we know the year provided was in the past but not before they were born.”

And this is my function:

function howOld(age, year) {
  let currentDate = new Date();
  let currentYear = currentDate.getFullYear();
  let yearsDifference = year - currentYear
  let calculatedAge = age + yearsDifference
  let birthYear = currentYear - age
  let beforeYear = birthYear - year 
  let pastYearAfterBirth = year - birthYear
  if (year > currentYear) {
    return `You will be ${calculatedAge} in the year ${year}`
  } else if (year < birthYear) {
    return `The year ${year} was ${beforeYear} years before you were born`
  } else if (year < currentYear && year > birthYear) {
    return `You were ${pastYearAfterBirth} in the year ${year}`
  }
}

After seeing the hint i realised i could have done it much more simple, clean and smart, but it seems i’m not that efficient in my thinking – can someone please point me to some kind of exercises or something that i can study to improve the way i think these exercises and coding logic in general? I’m 35 and i really want to learn.