Created
October 4, 2019 14:12
-
-
Save angelique-w/9d36d06a617a01004cc4fc27b57ee4b1 to your computer and use it in GitHub Desktop.
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
process.stdin.resume() | |
process.stdin.setEncoding('utf8') | |
console.log('What\'s your age ? ') | |
process.stdin.on('data', age => { | |
const today = new Date(); | |
const yearofBirth = today.getFullYear() - age; | |
console.log(((Number(age)) && (age <= 99) && (age < today)) ? `You were born in ${yearofBirth}` : 'The entry is incorrect') | |
process.exit() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment