Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
88
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. console.log('How old are you ?')
  5. process.stdin.on('data', (age) => {
  6. const currentDate = new Date();
  7. const currentYear = currentDate.getFullYear();
  8. let year;
  9. if (!isNaN(age))
  10. year = parseInt(age)
  11. if (year !=null)
  12. if (age < 99) {
  13. let calculAnnee = currentYear - age;
  14. console.log(calculAnnee)
  15.  
  16. } else {
  17. AskAge(age);
  18. }
  19. process.exit()
  20. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement