How to enter a string in the console?

Using the module simple-twitter wrote a simple script which creates a tweet with the specified text in quotation marks. But I want to implement so that when you run the script from console it output would console.log("tweet what to write "); and I would put in some variable its own line, so that's the way you can enter numbers and strings into variables in node.js ? I know that in js there but they confitm prompt in the browser interface.
June 27th 19 at 15:05
1 answer
June 27th 19 at 15:07
Solution
process.stdin.read();
ff221ab1f0874a3f8094dcc8fb489c2f.png
So to use it ? - Lindsey_Cole commented on June 27th 19 at 15:10
A Doc to look weak?
Let inputtext = process.stdin.read(); - sally_Carro commented on June 27th 19 at 15:13
: https://nodejs.org/dist/latest-v7.x/docs/api/proce... - sally_Carro commented on June 27th 19 at 15:16
or parentheses to pass the variable simply did not more do not work - Lindsey_Cole commented on June 27th 19 at 15:19
: go to the link, everything works. - sally_Carro commented on June 27th 19 at 15:22
: already running, but the program falls into an infinite loop, query text and send how to fix this ?c95938c870f54e408bfd30d44edaed44.png - Lindsey_Cole commented on June 27th 19 at 15:25
:
const readline = require('readline');

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

rl.question('What do you think of Node.js? ', (answer) => {
 // TODO: Log the answer in a database
 console.log(`Thank you for your valuable feedback: ${answer}`);

rl.close();
});

The second option

PS: from here - sally_Carro commented on June 27th 19 at 15:28

Find more questions by tags Node.jsJavaScript