Scoring a Javascript Quiz Script
<p>Hi I some javascript code written to quiz the user on 5 questions and then in theory output their score. As far as I can tell the questions are being scored, I just can't figure out how to output the response. I am having no issues fetching the correct html elements and displaying them. I believe the issue is in the looping elements of the window.onload function. The code is below,</p>

<pre><code>&lt;script type="text/javascript"&gt; 
var rand = 0;
var right = 0;
window.onload = function () {
    reset();
    Rrand();
    var rangQ = document.getElementById('area').getElementsByClassName('divide');
    correct = document.getElementsByTagName('a'), i = 0;
    for (i; i &lt; correct.length; i++) {
        if (correct[i].className == 'correct') {
            correct[i].onclick = function () {
                right++;
                reset();
                Rrand();
            }
        }
        else if (correct[i].className != 'correct') {
            correct[i].onclick = function () {
                right--;
                reset();
                Rrand();
            }
        }
    }
}
function Rrand() {
    var rangQ = document.getElementById('area').getElementsByClassName('divide');
    rangQ[rand].style.display = '';
    rand++;
}
function reset() {
    var rangQ = document.getElementById('area').getElementsByClassName('divide');
    for (var i = 0; i &lt; rangQ.length; i++) {
        rangQ[i].style.display = 'none';
    }
}
document.write(right);
&lt;/script&gt;
</code></pre>
