Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- process.stdin.resume()
- process.stdin.setEncoding('utf8')
- const YEAR = 2018
- console.log('What\'s your age ?')
- process.stdin.on('data', function (age) {
- if (age > 0 && age <= 99) {
- age = parseInt(age)
- }
- if (typeof age !== 'number') {
- process.stdout.write('Do you know how to read?')
- process.exit()
- } else {
- let birthYear = YEAR - age
- process.stdout.write('You are born in ' + birthYear + '!')
- process.exit()
- }
- })
Add Comment
Please, Sign In to add comment