Hello everyone, I’m stuck and need help! The following code is bringing back "You were NaN in the year 2050. It should be returning “You will be 67 in the year 2050”. Can anyone please tell me why it is doing this?
A link to the exercise is as follows: http://codecademy.com/paths-redirect/5b32457b646caa5007c30975/dfbca5c79d1142fc8dcdc09c064f00b6/exercises/how-old
const howOld = (age, year) => {
const yearDifference = year - theCurrentYear
var theCurrentYear = 2021
const newAge = age + yearDifference
if (newAge < 0) {
console.log('The year' + year + ' was ' + -newAge + ' years before you were born');
}
else if (newAge > age) {
console.log('You will be ' + newAge + ' in the year ' + year);
}
else {
console.log('You were ' + newAge + ' in the year ' + year);
}
}
howOld(37, 2050)