-
-
Save codecademydev/b1c63ffe00e58b44ea20d1a38da39b69 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write your function here: | |
const howOld = (age, year) => { | |
let futureAge = (year - 2021 + 30) | |
let pastAge = (year - 1991) | |
let notBornYet = 1991 - year | |
if (year > 2021) { | |
return (`You will be ${futureAge} in the year ${year}`) | |
} | |
if (year < 1991) { | |
return (`The year ${year} was ${notBornYet} years before you were born`) | |
} | |
if (year < 2021 && year > 1990) { | |
return (`You were ${pastAge} in the year ${year}`) | |
} | |
} | |
console.log(howOld(30, 1960)) | |
console.log(howOld(30, 2009)) | |
console.log(howOld(30, 2096)) | |
// Once your function is written, write function calls to test your code! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment