我试图只使用javascript和HTML而没有外部库来制作一个简单的测验系统.但我遇到了一些问题.该脚本提供了错误的解决方案.即使我选择了正确的复选框,它也只输出1个正确答案.我不知道我到底做错了什么,或者是否有其他方法可以做到这一点.
<div class="quizsection">
<button onclick="startQuiz()" id="startQuiz">Start Quiz</button>
<div id="questions"></div>
</div>
<script>
//Create Array with questions and solutions
var allQuestions = [{
question: "Before Mt. Everest was discovered, whaich mountain was considered to be the highest mountain in the world?",
choices: ["Mt. Kilimanjaro", "Kanchenjunga", "Mount Everest"],
correctAnswer: 1
},
{
question: "Does England have a 4th of July?",
choices: ["Yes", "No", "I don't know"],
correctAnswer: 0
},
{
question: "What is Rupert the bear's middle name?",
choices: ["Bear", "He doesn't have …Run Code Online (Sandbox Code Playgroud)