[英]multiple strings inside object array in javascript
so id like to add multiple answers to this array:所以我想为这个数组添加多个答案:
var questions = [
{
prompt: "What is the maori translation for:
\"Apple\"\n(a).Aporo\n(b).Ako
\n(c).Whanaunga\n(d).Pene rākau",
answer: "a"
}
something like "answer: "a" || "aporo" is that possible? Any answer would be very much appreciated uwu像“答案:“a”||“aporo”这样可能吗?任何答案都会非常感谢uwu
I would go down a different path.我会走不同的道路。
Think of your question as containing multiple possible answers, and then save them as such.将您的问题视为包含多个可能的答案,然后将它们保存为这样。
Instead of 1 question with 1 answer, consider 1 question with several possible answers, any number marked correct.考虑 1 个问题和多个可能的答案,而不是 1 个问题和 1 个答案,任何标记为正确的数字。 So I would build it up like this:
所以我会像这样构建它:
var questions = [
{"question":"What is the maori translation for: \"Apple\"?",
"PossibleAnswers":
[{"text":"Aporo","correct":true},
{"text":"Ako","correct":false},
{"text":"Whanaunga","correct":false},
{"text":"Pene rākau","correct":false}
]},
{"question":"How many fingers on a hand?",
"PossibleAnswers":
[{"text":"3","correct":true},
{"text":"5","correct":false},
{"text":"10","correct":false},
{"text":"4 and 1 thumb","correct":true}
]},
{"question":"What is the maori translation for the french word: \"Pomme\"",
"PossibleAnswers":
[{"text":"Ako","correct":false},
{"text":"Whanaunga","correct":false},
{"text":"Aporo","correct":true},
{"text":"Pene rākau","correct":false}
]}
]
By doing it this way, you can both have multiple correct answers, and greater control of how you present your question to the respondent.通过这样做,您既可以有多个正确答案,也可以更好地控制向受访者提出问题的方式。
Something like this?像这样的东西?
var questions = [
{"question":"Some question text1", "answers": ["answer 1", "answer 2"]},
{"question":"Some question text2", "answers": ["answer 3", "answer 4"]},
{"question":"Some question text3", "answers": ["answer 5", "answer 6"]}
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.