Guest User

Untitled

a guest
Mar 24th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. process.stdin.resume()
  2. process.stdin.setEncoding('utf8')
  3.  
  4. const YEAR = 2018
  5. console.log('What\'s your age ?')
  6.  
  7. process.stdin.on('data', function (age) {
  8. if (age > 0 && age <= 99) {
  9. age = parseInt(age)
  10. }
  11. if (typeof age !== 'number') {
  12. process.stdout.write('Do you know how to read?')
  13. process.exit()
  14. } else {
  15. let birthYear = YEAR - age
  16. process.stdout.write('You are born in ' + birthYear + '!')
  17. process.exit()
  18. }
  19. })
Add Comment
Please, Sign In to add comment