1. We are creating js multiple choice question
Screenshot of multiple choice question answer
We creating a separate article element for each question and its answers. Here all the answer are creating through checkbox element.
Each checkbox value is the question number start from 0 and an answer value.
Eg <input type=”checkbox” id=”options00″ value=”0:Modi” name=”option0″>Modi
We have two for loop, first is iterating through each question and second j for loop is for iterating through each answer options of that particular question.
Where 0 is the first question and Modi is a value of checkbox answer of that question.
In above code, we are iterating through each answer to that particular question and check if the answer is correct. For the first question, we have to iterate 3 times in answer and 2 iterations for the second answer. As the filter will create a new array containing correct checkbox answer.
showResults to create element containing the score result and we have used remove function to delete the existing score result node. So that duplication of score element will remove when ever new score is created.
We are using function