Guest User

Untitled

a guest
Mar 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. process.stdin.resume()
  2. process.stdin.setEncoding('utf8')
  3.  
  4. const anneeCourante = 2018;
  5. let age = 0;
  6.  
  7. console.log('What\'s your age ? ');
  8.  
  9. process.stdin.on('data', (age) => {
  10. if (isNaN(age)) {
  11. console.log("Value must be a number, learn to read N@@b");
  12. process.exit();
  13. }
  14. else if (age > 99 || age <= 0) {
  15. console.log("this test doesn\'t apply to mummies or unborns :o");
  16. process.exit();
  17. }
  18. else {
  19. let DoB = (anneeCourante - age);
  20. DoB = Math.round(DoB);
  21. console.log("ah so you\'re born in " + DoB);
  22. process.exit();
  23. }
  24. })
Add Comment
Please, Sign In to add comment