Created
November 14, 2016 15:02
-
-
Save Ludovicmoreau/7c7d9cf3b724bbe5d9dc1a7b224d8e3a to your computer and use it in GitHub Desktop.
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('Quel est votre âge ? '); | |
process.stdin.on('data', function(text) { | |
if (isNaN(text)) { | |
console.log('Valeur incorrecte, veuillez entrer un nombre.'); | |
process.exit(); | |
} else { | |
if (text > 99 || text < 0 ) { | |
console.log("Vous êtes soit trop jeune, soit trop vieux pour écrire sur un ordinateur"); | |
process.exit(); | |
} else { | |
var date = new Date(); | |
var current_year = date.getFullYear(); | |
console.log("Ta date de naissance esst " + (current_year - text)); | |
process.exit(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment