Answers for "recursive inquirerjs prompts"

0

recursive inquirerjs prompts

const inquirer = require("inquirer");

let strategies = [];
let repeat = true;
do {
  strategies.push(
    await inquirer.prompt([
      {
        type: "input",
        name: "firstname",
        message: "Enter firstname",
      },
      {
        type: "input",
        name: "lastname",
        message: "Enter lastname",
      },
    ])
  );
  repeat = (
    await inquirer.prompt([
      {
        type: "confirm",
        name: "repeat",
        message: "Do you want to add another person ?",
      },
    ])
  ).repeat;
} while (repeat);

console.log(strategies);
/* Output :
[
	{firstname: "first", lastname: "lastname"},
    ...
    {firstname: "last", lastname: "lastname"}
]
*/
Posted by: Guest on April-13-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language