Creating a five question quiz with four answers each was a challenging task. Now, I want to store each question/answer combination in its own position in an array. Here is a snippet of the HTML code I've written:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8>
<link rel="stylesheet" type="text/css" href="SQ.css">
<script src="SQ.js"></script>
<title>'Simple Quiz'</title>
</head>
<h3>Let's Test Your Knowledge!!</h3>
<body>
<div id="question1" class="div activequestion">
<p>What is the capital of Washington?</p>
<input type="radio" class="input" id="q1" name="Q1">Salem
<br>
<input type="radio" class="input" id="q1" name="Q1">Seattle
<br>
<input type="radio" class="input" id="q1" name="Q1">Olympia
<br>
<input type="radio" class="input" id="q1" name="Q1">Helena
</div>
<div id="question2" class="div">
<p>How many countries are in Europe?</p>
<input type="radio" class="input" id="q2" name="Q2">51
<br>
<input type="radio" class="input" id="q2" name="Q2">15
<br>
<input type="radio" class="input" id="q2" name="Q2">46
<br>
<input type="radio" class="input" id="q2" name="Q2">27
These are only the first two questions of my quiz.
I am looking for a way to define an array with question one answer 3 being [0, 2], and so on. Should this be done in the Javascript section of my code or directly in the HTML, maybe within the div tags for each question/answer?
Moreover, how can I validate the answers at the end of the quiz using this array format? Here's the link to the fiddle. Any assistance would be greatly appreciated!