Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- process.stdin.resume()
- process.stdin.setEncoding('utf8')
- console.log('What\'s your age ? ')
- process.stdin.on('data', (text) => {
- text = parseInt(text, 10);
- if (typeof text === 'number' && text < 100 && text > 0) {
- const birthYear = 2019 - text;
- console.log(`Your date of birth is ${birthYear}`);
- } else {
- console.log(`The age must be a number & less than a hundred`);
- }
- process.exit()
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement