Advertisement
Guest User

Untitled

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