Answers for "take an input nodejs"

7

input in node js

const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
 
readline.question('who are you: ', name => {
	console.log(`hello, hi there ${name}`);
	readline.close();
})
Posted by: Guest on February-18-2021
2

get input in terminal nodejs

const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

readline.question('Who are you?', name => {
  console.log(`Hey there ${name}!`);
  readline.close();
});
Posted by: Guest on May-27-2021
2

getting user input in node js

//Make sure you have Node and NPM installed
//Run "npm install prompt-sync" in the terminal
const prompt = require('prompt-sync')();

const name = prompt('What is your name?');
console.log(`Hey there ${name}`);
Posted by: Guest on December-20-2021
0

node js get input from console

--------------- easiest method I found---------------------------
  
Run npm install prompt-sync in the terminal
const prompt = require('prompt-sync')();

var name = prompt('what is your name?');

console.log(name);

--------------------------------------------------------------
Posted by: Guest on March-25-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language