Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

253
Views
How is it possible in Node js to display list of options via console log and ask user to input a option from the displayed list via console log

How is it possible in Node js to display list of options via console log and ask user to input a option from the displayed list via console log

Expected behavior user@desktop:~$ node test.js

  1. Option 1
  2. Option 2
  3. Option 3

Select option to continue: 3 You have selected option 3

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Figured out a method using inquirer module

const inquirer = require('inquirer');
function main() {
inquirer
  .prompt([
    {
      type: 'list',
      name: 'Options',
      message: 'Select an Item from below list',
      choices: ['alligator', 'crocodile', 'Exit'],
    },
  ])
  .then(answers => {
        if (answers.Options == "Exit"){
                process.exit()
        } else {
                console.info('Answer:', answers.Options);
        }
  });
}
if (require.main === module) {
  main();
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!