Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created November 13, 2021 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/b1c63ffe00e58b44ea20d1a38da39b69 to your computer and use it in GitHub Desktop.
Save codecademydev/b1c63ffe00e58b44ea20d1a38da39b69 to your computer and use it in GitHub Desktop.
Codecademy export
// 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