I'm trying to read test casevalue from stdin and then I will read a different N value from stdin.
E.g:
If T = 3
I could have N = 200, N = 152, N = 35263
It's the first time I work with readline:
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.on('line', (line) => {
for (let i = 0; i < line; i++) {
rl.on('line', (N) => {
console.log('N: ', N);
})
}
})
When I test the code I got this:
3
1
N: 1
N: 1
N: 1
It read only one value of N and I can't enter the 2 different values then it displays the N = 13 times.
How can I fix that to read the different value of N according to the number of test cases?