Skip to content

Instantly share code, notes, and snippets.

@alyson-b69
Last active June 22, 2020 06:29
Show Gist options
  • Save alyson-b69/aceffd44bfd17f6636f9afa29efdfbfe to your computer and use it in GitHub Desktop.
Save alyson-b69/aceffd44bfd17f6636f9afa29efdfbfe to your computer and use it in GitHub Desktop.
Decouverte nodeJS
process.stdin.resume()
process.stdin.setEncoding('utf8')
// console.log('What\'s your name ? ')
// process.stdin.on('data', (text) => {
// console.log('Hello ' + text)
// process.exit()
// });
console.log('What\'s your age ? ')
process.stdin.on('data', function( yourAge ) {
if ( ( yourAge <= 99 ) && ( yourAge > 0) ) {
console.log( 'You was born in :' + ( 2020 - yourAge ) )
process.exit()
} else if ( yourAge >= 99 ) {
console.log( 'You\'re to older.' )
process.exit()
} else {
console.log( 'Try again !' )
process.exit()
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment