Last active
April 15, 2018 12:28
-
-
Save TheCodingLady/3b43c9eb21552c555280c9e03fd9a178 to your computer and use it in GitHub Desktop.
NodeJS-quête1
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', (number) => { | |
if (!isNaN(number) && number < 99) { | |
console.log('You were born in ' + (2018 - number)) | |
process.exit() | |
} else { | |
console.log('Enter your age only if you are between 1 and 99') | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment