Skip to content

Instantly share code, notes, and snippets.

@Ludovicmoreau
Created November 14, 2016 15:02
Show Gist options
  • Save Ludovicmoreau/7c7d9cf3b724bbe5d9dc1a7b224d8e3a to your computer and use it in GitHub Desktop.
Save Ludovicmoreau/7c7d9cf3b724bbe5d9dc1a7b224d8e3a to your computer and use it in GitHub Desktop.
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