Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. process.stdin.resume()
  2. process.stdin.setEncoding('utf8')
  3.  
  4. let thisDay = new Date();
  5. let thisYear = thisDay.getFullYear();
  6. console.log('We are ' + thisDay +' in '+ thisYear);
  7.  
  8. console.log('What will be your age at the end of this year? ')
  9. process.stdin.on('data', (myAge) => {
  10. myAge = Number(myAge);
  11. if(myAge>0 && myAge<99){
  12. let myBirthYear = thisYear - myAge;
  13. console.log('Your age is ' + myAge);
  14. console.log('You were born in ' + myBirthYear);
  15. } else {
  16. console.log('Please enter a valid NUMBER inferior or equal to 99. Even if you\'re THAT OLD...');
  17. }
  18. process.exit();
  19. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement