Sunday 28 June 2020

How to eliminate ">" character from output buffer when using the "prompt()" from the "readline" package?

I need to make an application that takes input from the user in the following form:n k (two integers separated by space on one line)a b c d .... infinity(n integers separated by space on one line)My code accomplishes the task, but when I use the prompt function, node automatically prints on the output buffer a ">" character next to which I have to enter my input. I need to get rid of that, because my program's output is automatically being checked and parsed against expected output automatically.const readline = require('readline');const rl = readline.createInterface({input: process.stdin,output:process.stdout});let n;let k;let rezultatu;let numere=[];rl.question(``,                (userInput)=>{let vector=userInput.split(' '); //n and k separated by spacen=vector[0];k=vector[1];rl.prompt(); ////////////////////////////This is where it gets nastyrl.on('line',(userInput)=>{numere=userInput.split(' ');rl.close();                })                });

Submitted June 29, 2020 at 12:59AM by NaturallyElected

No comments:

Post a Comment