Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- process.stdin.resume();
- process.stdin.setEncoding('utf8');
- console.log('How old are you?');
- process.stdin.on('data', (age) => {
- const birthYear = 2019 - age;
- if (isNaN(age) === false && age >0 && age <= 99) {
- console.log(`You were born in ${birthYear}`);
- process.exit()
- }
- else if (age > 99) {
- console.log(`Sorry, you are too old to use this function.`);
- }
- else {
- console.log(`You should mention your age in numerical values.`);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement