Get your own Node server
// For Node.js v17 and above:
const readline = require('readline/promises');
const { stdin: input, stdout: output } = require('process');

async function askQuestions() {
  const rl = readline.createInterface({ input, output });

  try {
    // Ask questions sequentially
    const name = await rl.question('What is your name? ');
    console.log(`Hello, ${name}!`);

    const age = await rl.question('How old are you? ');
    console.log(`You are ${age} years old.`);

    const location = await rl.question('Where do you live? ');
    console.log(`${location} is a nice place!`);

    // Summary
    console.log('\nSummary:');
    console.log(`Name: ${name}`);
    console.log(`Age: ${age}`);
    console.log(`Location: ${location}`);
  } finally {
    // Make sure to close the interface
    rl.close();
  }
}

// Run the async function
askQuestions()
  .then(() => console.log('Questions completed!'))
  .catch(err => console.error('Error:', err));

              
What is your name? John
Hello, John!
How old are you? 30
You are 30 years old.
Where do you live? New York
New York is a nice place!

Summary:
Name: John
Age: 30
Location: New York
Questions completed!