My quiz has a bug in where if the correct answer is pressed multiple times, the score increases an infinite number of times?
https://stackoverflow.com/questions/76227565/my-quiz-has-a-bug-in-where-if-the-correct-answer-is-pressed-multiple-times-the
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Multiple Choice Page -->
<div class="page-multiple-choice">
<div id="beginning-screen-quiz">
<h1 id="heading-quiz">Oh no! it looks like you have been locked out of the computer system. You will have to
take this quiz in order to regain access, you must get a score of 60 in order to bypass the security system.
</h1>
<button id="start-button-quiz">Hack into security</button>
</div>
<h1>Multiple Choice Quiz</h1>
<div class="p2-button button">
Fix the circuit
</div>
<div class="p-menu-button button">
Go back to menu
</div>
<div id="wrapper">
<div id="question">Sample question here</div>
<div id="answersAndFeedback">
<div id="answer1" class="answer-box">Answer 1</div>
<div id="answer2" class="answer-box">Answer 2</div>
<div id="answer3" class="answer-box">Answer 3</div>
<div id="feedback" class="hidden">Feedback goes here</div>
</div>
<div class="score">0</div>
<div id="next-btn" class="hidden">next</div>
<div id="game-over" class="hidden">Congratulations! Continue to the next page!</div>
</div>
</div>
JavaScript
// --------------------------- Multiple Choice Page functions and variables -------------------------------------
// Study Page
var currentBox = 1;
var numBoxes = $('.text-box').length;
// variables here
var quizData = [
{
question: "If the size of a battery in a complete circuit is increased:",
answers: ["the current decreases", "the current increases", "the voltage stays the same"],
correctAnswer: 2,
feedback: "An increase in voltage will increase the current flowing in a circuit (if nothing else is changed) Click to next page find out more."
},
{
question: "The current in a series circuit containing two bulbs:",
answers: ["is the same at every place in the circuit", "is larger nearer the battery", "is larger between the bulbs"],
correctAnswer: 1,
feedback: "This is an important point to remember about a series circuit. Click to next page find out more."
},
{
question: "Two identical bulbs are in parallel in a complete circuit. If one breaks:",
answers: ["the other stays on", "the other goes off", "the other bulb is brighter"],
correctAnswer: 1,
feedback: "This is a benefit of a parallel circuit, it is usually easier to find out which component has broken as the rest still work"
},
{
question: "Wires are usually coated in plastic because:",
answers: ["plastic is an insulator", "plastic can be lots of different colours", "plastic helps the wires conduct electricity"],
correctAnswer: 1,
feedback: "Wires used to be covered with rubber as an insulator but rubber perishes faster than plastic."
},
{
question: "Which of the following statements is true?",
answers: ["A voltmeter is connected in series to measure voltage.", "Different sized bulbs in parallel have...