I want to get user input from user. I have created a function to do that by taking the code from node.js documentation. But I cannot receive multiple user inputs. How can I do that? This is the code so far.
function getUserInput() {
rl.question('Please input a letter: ', (answer) => {
console.log('Letter entered: ${answer}');
rl.close();
});
}
//getUserInput();
var k=0;
while ( k < 3 ){
getUserInput();
k++;
}
I expect to take for example 3 user inputs. I want to take user input. With the code above I can only take only ONE user Input. I thought adding the function into a loop so it could work. I am looking for any modification into my code so It can work and so I can take more than one user input.