Last active
June 22, 2020 16:33
-
-
Save justinehell/98fc81f83f2415cfb2624c2213e2af24 to your computer and use it in GitHub Desktop.
Découverte de 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('Please enter your age') | |
| process.stdin.on('data', (age) => { | |
| let actualYear = new Date().getFullYear(); | |
| if (typeof(parseInt(age)) === "number" && parseInt(age) < 100 && parseInt(age) > 0) { | |
| console.log(`Year of your birth : ${actualYear - age}`); | |
| process.exit(); | |
| } else { | |
| console.log("Invalide input, try again !") | |
| } | |
| }) | |
| /* Merci Nico ^^ */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment