How to write a quiz with JavaScript?
<p>I'm still new to JavaScript, and I'm trying to write a quiz that will send a person to one of 3 pages depending on the answers they choose (so each time they pick an "x" answer, <code>x</code> will increase by one).</p>

<p>With the code I've written so far I've got two problems.  </p>

<ul>
<li><p>The variable values aren't increased by one so maybe I've written that wrong.  </p></li>
<li><p>I'm not sure how to pick the variable with the most checked answers to send them to the relating page. </p></li>
</ul>

<p>I tried writing an <code>if</code> statement to show what I mean. Any thoughts on how to improve this would be greatly appreciated, or if a whole other approach would be better I'm open to that.</p>

<pre><code>var x = 0;
var y = 0;
var z = 0;

function question1(){
    if (document.getElementById('a1').checked) {
        x++;        
    }
    else if (document.getElementById('a2').checked) {
        y++; 

    } else if(document.getElementById('a3').checked){
        z++;
    }
}
function question2(){
    if (document.getElementById('b1').checked) {
        x++;        
    }
    else if (document.getElementById('b2').checked) {
        y++; 

    } else if(document.getElementById('b3').checked){
        z++;
    }
}
function result(){
    Math.max(x,y,z);
    if (x){
       alert("You chose x");
    } else if (y){
        alert("You chose y");
      } else if (z){
          alert("You chose z");
        }

}
</code></pre>
