“NodeJS Wejście użytkownika” Kod odpowiedzi

Wejście w węźle 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();
})
Poised Panda

Uzyskanie danych wejściowych użytkownika w węźle 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}`);
Blushing Beetle

Jak przyjmować dane wejściowe z NodeJS użytkownika

const prompt = require("prompt-sync")();

const input = prompt("What is your name? ");

console.log(`Oh, so your name is ${input}`);
Clever Crossbill

Węzeł JS otrzymuje dane wejściowe z konsoli

--------------- 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);

--------------------------------------------------------------
Kriss Sachintha

NodeJS Wejście użytkownika

// Importing the module
const readline = require("readline-sync");
  
// Enter the number
let a = Number(readline.question());
let number = [];
for (let i = 0; i < a; ++i) {
  number.push(Number(readline.question()));
}
console.log(number);
Delightful Dolphin

Odpowiedzi podobne do “NodeJS Wejście użytkownika”

Pytania podobne do “NodeJS Wejście użytkownika”

Więcej pokrewnych odpowiedzi na “NodeJS Wejście użytkownika” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu