Last active
September 9, 2018 20:41
-
-
Save MattCrl/51224d3f04cac75edc5d6e2f4775c244 to your computer and use it in GitHub Desktop.
This file contains 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 age ?') | |
process.stdin.on('data', (age) => { | |
if (age <= 99 && age >= 0) { | |
let year = 2018 - age | |
console.log('Born in ' + year) | |
} | |
if (age > 99) { | |
console.log('You can\'t have more than 99 years old !') | |
} | |
if (age < 0) { | |
console.log('You can\'t have a negative age !') | |
} | |
if (isNaN(age)) { | |
console.log('Please enter a valid age') | |
} | |
process.exit | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment