There is such a task
go input
string 1
Line 2.
Row 3.
... etc.
This is not one line. So how to read all the lines?
An example of I / O for JS:
const readline = require ('readline');
Const RL = readline.createInterface (process.stdin, process.stdout);
RL.ON ('Line', (Line) = & gt; {
// Entered line in the LINE variable, here you can write a solution
Console.log (String (RESULT));
RL.Close ();
Return;
}) ON ('Close', () = & gt; process.exit (0));
Next, I need to handle the strings for example
line.split ("\ n");
But I only get the first string if you remove the rl.close ()
then the first line falls into the function. I can’t understand how to write to a variable or array all lines.
Thank you.
Answer 1
may be the reason in rl.close ();
So works as it should
const readline = require ('readline');
Const RL = readline.createInterface ({
Input: Process.stdin,
Output: Process.stdout.
});
RL.ON ('Line', line = & gt; {
Console.log (Line);
}) ON ('Close', () = & gt; {
Console.log ('exit');
Process.exit (0);
});