Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. process.stdin.resume()
  2. process.stdin.setEncoding('utf8')
  3.  
  4. console.log('What\'s your age ? ')
  5. process.stdin.on('data', (age) => {
  6. const birthYear = new Date().getFullYear() - age;
  7.  
  8. if (isNaN(age) || age > 99){
  9. console.log('You must enter a number less than 99 !!!! ')
  10. process.exit()
  11. } else if (birthYear === 2019){
  12. console.log('ERROR !! You can not enter 0')
  13. process.exit()
  14. } else {
  15. console.log('You were born in '+ birthYear)
  16. process.exit()
  17. }
  18. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement