Q: Input prompt with options yeoman I'm new to programming, and I'm creating a generator with yeoman-generator. How do I go through an array of objects and select the option I choose? I tried it but it didn't work. can you help me?

prompting() {

const prompts = [
 {
   type: 'checkbox',
   name: 'database',
   message: 'Select Database support:',
   choices: [
                {
                    name: 'H2',
                    value: 'h2',
                }, {
                    name: 'HSQLDB',
                    value: 'hsqldb'

                }, {
                    name: 'Apache Derby',
                    value: 'derby'
                },
    ]
    return this.prompt(prompts).then(answers => {
       this.database = answers.database;
       const hasDataBase = db => this.database.indexOf(db) !== -1;
       this.h2 = hasDataBase('h2');
       this.hsqldb = hasDataBase('hsql');
       this.derby = hasDataBase('derby');
    });
}
]}




A: This is the format it can take (from their example page https://yeoman.io/authoring/user-interactions.html). I tested this myself and it works.
var Generator = require('yeoman-generator');

module.exports = class extends Generator {
  async prompting() {
    const prompts = await this.prompt([
      {
        type: 'checkbox',
        name: 'database',
        message: 'Select Database support:',
        choices: [
          {
            name: 'H2',
            value: 'h2',
          }, {
            name: 'HSQLDB',
            value: 'hsqldb'

          }, {
            name: 'Apache Derby',
            value: 'derby'
          }
        ]
      }]);

    this.log("database", prompts.database);
  }
};

