我想通过检查是否选中了is_answer = 1来检查答案是否正确并显示正确的单词或是否显示错误
我在数组vm.quiz_multi_answer = [];
vm.quiz_multi_answer.push();
中返回答案
我想遍历所有选择,以将所选答案与is_answer
vm.quiz_multi_data = [
{
question: "What does HTML stand for?",
choices: [
{
id: "0",
choice: "HyperText Markup Language",
is_answer: "1"
},
{
id: "1",
choice: "HyperText Markup Language",
is_answer: "1"
},
{
id: "2",
choice: "HyperText Markup Language",
is_answer: "0"
},
{
id: "3",
choice: "HyperText Markup Language",
is_answer: "0"
}
]
}
];
答案 0 :(得分:0)
您可以像这样
for(let i =0 ;i < quiz_multi_data.length ; i ++ ){
if(quiz_multi_data[i].question/_id == "any_question_veriable"){
for(let j =0 ; j < quiz_multi_data[i].choices[j].length ; j++ ){
if( quiz_multi_data[i].choices[j]._id == id){
//perform some logic
}
}
}