Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. process.stdin.resume();
  2. process.stdin.setEncoding('utf8');
  3.  
  4. console.log('How old are you?');
  5.  
  6. process.stdin.on('data', (age) => {
  7. const birthYear = 2019 - age;
  8.  
  9. if (isNaN(age) === false && age >0 && age <= 99) {
  10. console.log(`You were born in ${birthYear}`);
  11. process.exit()
  12.  
  13. }
  14. else if (age > 99) {
  15. console.log(`Sorry, you are too old to use this function.`);
  16. }
  17. else {
  18. console.log(`You should mention your age in numerical values.`);
  19. }
  20. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement