Skip to content

Instantly share code, notes, and snippets.

@picpoint
Created April 28, 2019 09:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save picpoint/7cda9cd0cd24583e551dd72dcab1a326 to your computer and use it in GitHub Desktop.
Save picpoint/7cda9cd0cd24583e551dd72dcab1a326 to your computer and use it in GitHub Desktop.
simple code to IO in Nodejs
const stdin = process.stdin;
const stdout = process.stdout;
stdout.write('Enter you name -> ');
stdin.on('data', function (data) {
stdout.write('Your name is -> ');
var name = data.toString().trim();
stdout.write(name + '\n');
stdout.write('Your name to reverse -> ' + name.toString().split('').reverse().join('') + '\n');
process.exit();
});
process.on('exit', function () {
stdout.write('App is completed\n');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment