Basically, I am trying to write a very basic program that will work as follows:
Enter your name: _ Enter your age: _ Your name is <name> and your age is <age>.
I tried to figure out how to do something like this in Node without using the prompt npm module.
My attempt:
import readline from 'readline' const rl = readline.createInterface({ input: process.stdin, output: process.stdout }) rl.question('What is your name? ', (name) => { rl.question('What is your age? ', (age) => { console.log(`Your name is ${name} and your age is ${age}`) }) })
However, this nested way of doing this seems weird, is there anyway I can do it without making it nested, how is it to get the correct order?
source share