I have a 10 question multiple choice quiz. I created an array with the correct answers in it. Each question has 4 radio buttons.
for each group, the data is a,b,c,d and put in groups q1, q2, q3, q4 etc all the way to q10.
Now I am trying to make a loop that checks if they answered them correctly and have this so far:
var answers:Array = new Array("b", "a", "c", "d", "c", "a", "c", "b", "c", "d");
_parent._parent._parent.submit.onRelease = function() {
var testLength:Number = answers.length;
for (var i = 1; i <= testLength; i++) {
var question = i;
checkScore(question);
}
};
function checkScore(question:Number) {
//trace(question);
if (this["q" + question].selectedData == answers[question]) {
trace(question + " is correct");
} else {
trace(question + " is wrong");
}
}
I am checking this when I hit a button and its tracing out this no matter what I select…
1 is wrong
2 is wrong
3 is wrong
4 is wrong
5 is wrong
6 is wrong
7 is wrong
8 is wrong
9 is wrong
10 is correct
any idea what I am doing wrong?