Last active
June 22, 2020 06:29
-
-
Save alyson-b69/aceffd44bfd17f6636f9afa29efdfbfe to your computer and use it in GitHub Desktop.
Decouverte nodeJS
This file contains hidden or 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 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