Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let standard_input = process.stdin;
- // Set input character encoding.
- standard_input.setEncoding('utf-8');
- // Prompt user to input data in console.
- console.log("How old are u ?");
- // When user input data and click enter key.
- standard_input.on('data', function (data) {
- data = parseInt(data)
- if (typeof data === 'number' && data < 99) {
- // Print user input in console.
- const today = new Date();
- const currentYear = today.getFullYear();
- const age = currentYear - data
- console.log("Your are born in "+age);
- }
- process.exit();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement