Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- process.stdin.resume()
- process.stdin.setEncoding('utf8')
- let thisDay = new Date();
- let thisYear = thisDay.getFullYear();
- console.log('We are ' + thisDay +' in '+ thisYear);
- console.log('What will be your age at the end of this year? ')
- process.stdin.on('data', (myAge) => {
- myAge = Number(myAge);
- if(myAge>0 && myAge<99){
- let myBirthYear = thisYear - myAge;
- console.log('Your age is ' + myAge);
- console.log('You were born in ' + myBirthYear);
- } else {
- console.log('Please enter a valid NUMBER inferior or equal to 99. Even if you\'re THAT OLD...');
- }
- process.exit();
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement