From the course: Node.js Essential Training

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Collecting information with readline

Collecting information with readline - Node.js Tutorial

From the course: Node.js Essential Training

Collecting information with readline

- [Instructor] Readline is a module that allows us to ask questions of our terminal user. It's a wrapper around the standard input, standard output process that allows us to easily control the user prompt without having to work directly with stdin and stdout. So let's go ahead and create a new file here in our start folder called ask. We'll say ask.js. And here we want to first import our readline function. We'll say require readline. And then we're going to create a variable called rl, which is going to again be this wrapper around standard input and standard output in what's called an interface. So the interface has an input, which will map to process standard input. And then output is process.standard output. Then we'll call rl.question. The first thing that this will take in is a string. So we'll say how do you like Node? Then we'll add a callback function here. So we'll take in the answer. And we'll say…

Contents