Skip to content

Instantly share code, notes, and snippets.

@dragonslayer77
Created April 8, 2019 09:10
Show Gist options
  • Save dragonslayer77/8458ba0f739b672cc36432eba10ec541 to your computer and use it in GitHub Desktop.
Save dragonslayer77/8458ba0f739b672cc36432eba10ec541 to your computer and use it in GitHub Desktop.
process.stdin.resume()
process.stdin.setEncoding('utf8')
const currentYear = new Date().getFullYear();
const birthYear = (age) => {
if (age.isNaN || age > 99) {
} else{
let numYears = currentYear - age;
if (numYears < currentYear) {
return numYears;
}
}
};
console.log('How old are you ? ')
process.stdin.on('data', (number) => {
console.log('You were born in the year ' + birthYear(number));
process.exit()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment