Skip to content

Instantly share code, notes, and snippets.

@lejonmanen
Created March 9, 2022 10:53
Show Gist options
  • Save lejonmanen/1759865308aa7ba08b913515be3c8436 to your computer and use it in GitHub Desktop.
Save lejonmanen/1759865308aa7ba08b913515be3c8436 to your computer and use it in GitHub Desktop.
Node script: how to get input from user in the console
const prompt = require('prompt-sync')()
/*
Before running this code, make sure to create an npm project:
npm init -y
npm install prompt-sync
node input.js
*/
// How to get input from user
let x = prompt('What is your name? ')
console.log(`Welcome ${x}!`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment