I’m building a single-page questionnaire app and I’m not sure what is the correct way to build my arrays for the questions. Also, is it bad practice to mix types of questions in this manner? (Single choice, multi-choice in same array?) Basically, I’m still trying to understand the advantages/disadvantages of the two basic approaches I’ve seen.
Option 1:
var hygiene = [
{
pageheader: "Self-Care"
}
{
q: "When was your last shower?",
choicetype: "radio",
a1: "Today",
a2: "Yesterday",
a3: "Two days ago",
a4: "I don't know"
}
{
q: "How much do you weigh today?",
choicetype: "keypad"
}
{
q: "Do you take any medications?",
choicetype: "radio",
a1: "Yes",
a2: "No"
}
{
q: "Which medications?",
choicetype: "multiselect",
a1: "Zostavax",
a2: "Percocet",
a3: "Actemra",
a4: "Cimzia",
a5: "Relprevv"
}
];
Option 2:
var hygiene = {
pageheader: "Self-Care",
question1: [
"When was your last shower?", "radio", "Today", "Yesterday",
"Two days ago", "I don't know"
],
question2: [
"How much do you weigh today?", "keypad"
],
question3: [
"Do you take any medications?", "radio", "Yes", "No"
],
question4: [
"Which medications?", "multiselect", "Zostavax", "Percocet",
"Actemra", "Cimzia", "Relprevv"
]
};
My recommendation is not to use either of them, but the following: