Suppose we are creating an application that would ask questions from a terminal user. It is an interface where we can read and write data that allows us to easily write code that would ask questions to the user and collect their answers.
so let’s take a look at how can we use Readline module. suppose we have a file questions.js
const readline = require("readline"); const r1 = readline.createInterface({ input: process.stdin, output: process.stdout, }); r1.question("how r you doing?", (answer) => { console.log(`Answer is ${answer}`); process.exit(); });
Output:
Tadda 🙂 ! it is done, hope you fine it interesting. if you want to know more about it you have checkout the official document at https://nodejs.org/api/readline.html#readline