Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
refactor: 💡 questions logic'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashi1997 committed Feb 15, 2021
1 parent 643448e commit 6bfe25e
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions trials/multiSurvey.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,19 @@ module.exports = function (options) {
...defaults,
...options,
};

// setting questions from prompts and answer choices
let questions = [];
const answers = Object.values(ansChoices);
prompts.forEach(function (prompt, index) {
let options = answers.length === 1 ? answers[0] : answers[index];
questions.push({
prompt: prompt,
options,
required: true,
});
});

Object.keys(ansChoices).length === 1
? prompts.forEach(function (prompt, index) {
questions.push({
prompt: prompt,
options: ansChoices[Object.keys(ansChoices)[0]],
required: true,
});
})
: prompts.forEach(function (prompt, index) {
questions.push({
prompt: prompt,
options: ansChoices[Object.keys(ansChoices)[index]],
required: true,
});
});
return {
type: responseType,
preamble: preamble,
Expand Down

0 comments on commit 6bfe25e

Please sign in to comment.