Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/455.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript中对象数组中的多个字符串_Javascript - Fatal编程技术网

javascript中对象数组中的多个字符串

javascript中对象数组中的多个字符串,javascript,Javascript,因此,我想在此数组中添加多个答案: 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" } 类似于“回答:“a”| |“aporo” 可能吗? 如果您有任何回答,我们将不胜感激 var questions = [ {"question":"Some que

因此,我想在此数组中添加多个答案:

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"
}
类似于“回答:“a”| |“aporo” 可能吗? 如果您有任何回答,我们将不胜感激

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"]}
]

我会走另一条路

将您的问题视为包含多个可能的答案,然后将其保存为可能的答案

不要用1个问题加1个答案,而是用几个可能的答案来考虑1个问题,任何一个数字都是正确的。
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}
      ]}
]
通过这种方式,你既可以得到多个正确答案,也可以更好地控制你如何向回答者提出问题