I am making a multiple choice quiz, but my program won't work. I am storing the score of each question in variable, which in this case is a
. I am trying to have one function determine all the scores, but for some reason it decides that num2
which is supposed to represent a
, is being created as its own variable. Please help.
All the images are stored locally so they won't show up, but the function works in telling what is right or wrong, the variable just doesn't store.
<!DOCTYPE html>
<html>
<body>
<h1>What Information did you retain?</h1>
<p id="Grade"></p>
<br>
<p>#1 Do I have a pet? </p>
<button type="button" onclick="button(1, a)">A. None</button><br>
<button type="button" onclick="button(0, a)">B. Yes a Dog</button>
<br>
<img id="myImage" src="which.jfif" style = float:right;width="200" height="180">
<br>
<script>
var a = 0;
var b = 0;
var c = 0;
var d = 0;
var e = 0;
var Awnser;
function button(num, num2) {
if (num == 1) {
if (num2 == 0) {
num2++
Awnser = "correct.jfif"
console.log(a);
}
} else {
Awnser = "wrong.jfif"
}
document.getElementById('myImage').src = Awnser;
}
</script>
</body>
</html>