我正在对考试应用程序做出反应。我有两个数组,一个是用户给出的答案,一个是正确答案。比较它们并没有显示正确的结果。我正在使用钩子,代码在 useEffect 钩子内。结果也没有显示正确的问题数量。
questions = [
{Qid: 1, Question: "This is question 1",
Answers:[{Ans1:"Answer1",IsCorrect:true}
{Ans2:"Answer2",IsCorrect:false}
{Ans3:"Answer3",IsCorrect:false}
{Ans4:"Answer4",IsCorrect:false}]},
{Qid: 2, Question: "This is question 2",
Answers:[{Ans1:"Answer1",IsCorrect:false}
{Ans2:"Answer2",IsCorrect:true}
{Ans3:"Answer3",IsCorrect:false}
{Ans4:"Answer4",IsCorrect:false}]},
{Qid: 3, Question: "This is question 3",
Answers:[{Ans1:"Answer1",IsCorrect:true}
{Ans2:"Answer2",IsCorrect:false}
{Ans3:"Answer3",IsCorrect:false}
{Ans4:"Answer4",IsCorrect:false}]},
{Qid: 4, Question: "This is question 4",
Answers:[{Ans1:"Answer1",IsCorrect:false}
{Ans2:"Answer2",IsCorrect:false}
{Ans3:"Answer3",IsCorrect:true}
{Ans4:"Answer4",IsCorrect:false}]}
]
keyquestions = [
{Qid: 1, Question: "This is question 1",
Answers:[{Ans1:"Answer1",IsCorrect:false}
{Ans2:"Answer2",IsCorrect:true}
{Ans3:"Answer3",IsCorrect:false}
{Ans4:"Answer4",IsCorrect:false}]},
{Qid: 2, Question: "This is question 2",
Answers:[{Ans1:"Answer1",IsCorrect:false}
{Ans2:"Answer2",IsCorrect:true}
{Ans3:"Answer3",IsCorrect:false}
{Ans4:"Answer4",IsCorrect:false}]},
{Qid: 3, Question: "This is question 3",
Answers:[{Ans1:"Answer1",IsCorrect:true}
{Ans2:"Answer2",IsCorrect:false}
{Ans3:"Answer3",IsCorrect:false}
{Ans4:"Answer4",IsCorrect:false}]},
{Qid: 4, Question: "This is question 4",
Answers:[{Ans1:"Answer1",IsCorrect:false}
{Ans2:"Answer2",IsCorrect:true}
{Ans3:"Answer3",IsCorrect:false}
{Ans4:"Answer4",IsCorrect:false}]}
]
慕斯709654
有只小跳蛙
翻翻过去那场雪
相关分类