title: Multiple Choice Quiz - getting score?
body: <p>I'm trying to create a simple multiple choice program in HTML but I'm having trouble with getting the user input and showing their score at the end. Could someone help me out? </p>
  
  <p>There are 10 questions to my multiple choice quiz and 4 choices per question.</p>
  
  <p>Here is one question for example: </p>
  
  <pre><code>&lt;li&gt;
  &lt;h3&gt;How many letters are there in "JS"?&lt;/h3&gt;
  &lt;input type="radio" name="question9" value="A"&gt;2&lt;br&gt;
  &lt;input type="radio" name="question9" value="B"&gt;1&lt;br&gt;
  &lt;input type="radio" name="question9" value="C"&gt;3&lt;br&gt;
  &lt;input type="radio" name="question9" value="D"&gt;4&lt;br&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>Here is the button I am using to show the user's results:</p>
  
  <pre><code> &lt;button onclick="returnScore()"&gt;View Results&lt;/button&gt;
  </code></pre>
  
  <p>And here is my current script:</p>
  
  <pre><code>var userInput = new Array();
  var answers = new Array(10);
  answers[0] = "B";
  answers[1] = "C";
  answers[2] = "A";
  answers[3] = "C";
  answers[4] = "D";
  answers[5] = "D";
  answers[6] = "D";
  answers[7] = "D";
  answers[8] = "C";
  answers[9] = "A";
  
  function getScore(){
  var score=0;
  var numQuestions=10;
  
  for (var i=0;i&lt;numQuestions;i++){
  if (userInput[i]==answers[i]){
  score += 1;
  }
  else{
  score += 0;
  }
  
  }
  return score;
  }
  function returnScore(){
  alert("Your score is "+getScore()+"/10");
  }
  </code></pre>
  
  <p>Thanks.</p>