I'm trying to get an input from a user to a console in node js a finite number of times, and run a function on each input. while or for loop doesn't work.
any help?
here is my code (litle simplified):
function foo(num)
{
console.log(num)
}
function ReadUseInput()
{
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
readline.question('Enter number...', num =>
{
foo(num)
readline.close();
});
}
//for (var i = 0; i < 10; i++)// this line isnt working - shows warning: MaxListenersExceededWarning: Possible EventEmitter memory leak detected
ReadUseInput()