Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. process.stdin.resume()
  2. process.stdin.setEncoding('utf8')
  3.  
  4. console.log('What\'s your age ? ')
  5. process.stdin.on('data', (text) => {
  6. text = parseInt(text, 10);
  7. if (typeof text === 'number' && text < 100 && text > 0) {
  8. const birthYear = 2019 - text;
  9. console.log(`Your date of birth is ${birthYear}`);
  10. } else {
  11. console.log(`The age must be a number & less than a hundred`);
  12. }
  13. process.exit()
  14. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement