1const inquirer = require("inquirer");
2
3let strategies = [];
4let repeat = true;
5do {
6 strategies.push(
7 await inquirer.prompt([
8 {
9 type: "input",
10 name: "firstname",
11 message: "Enter firstname",
12 },
13 {
14 type: "input",
15 name: "lastname",
16 message: "Enter lastname",
17 },
18 ])
19 );
20 repeat = (
21 await inquirer.prompt([
22 {
23 type: "confirm",
24 name: "repeat",
25 message: "Do you want to add another person ?",
26 },
27 ])
28 ).repeat;
29} while (repeat);
30
31console.log(strategies);
32/* Output :
33[
34 {firstname: "first", lastname: "lastname"},
35 ...
36 {firstname: "last", lastname: "lastname"}
37]
38*/