Skip to content

Instantly share code, notes, and snippets.

@TheCodingLady
Last active April 15, 2018 12:28
Show Gist options
  • Save TheCodingLady/3b43c9eb21552c555280c9e03fd9a178 to your computer and use it in GitHub Desktop.
Save TheCodingLady/3b43c9eb21552c555280c9e03fd9a178 to your computer and use it in GitHub Desktop.
NodeJS-quête1
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