title: I'm making a basic Quiz on Javascript, but I'm not getting any results at all. What are the errors in my code & what do i need to do?
body: <p>There are 3 criterions i need to fulfill:</p>
  <ul>
  <li>The script should display the number of correct answers and the
  percentage correct at the bottom of the quiz.</li>
  <li>Display the text ‘Well Done’ if all questions were
  answered correctly or ‘Try again’ if not.</li>
  <li>A hyperlink on 'Try Again' to reload the page.</li>
  </ul>
  <p>I haven't yet gotten to the second &amp; third criteria's because I'm not able display score for a trial of the first question.
  I've tried to use two different methods but since I haven't completely understood <code>switch</code>, I don't think I'm using it right.
  I have also tried to inspect element, but it does not show any errors.
  I'm still a student &amp; an amateur in JavaScript (&amp; coding in general) so I would appreciate solutions which are simple &amp; not overly complicated.</p>
  <p>Thanks!</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;title&gt;JS Quiz template&lt;/title&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
   &lt;div align="center"&gt;
      &lt;h3&gt;Quiz Trial&lt;/h3&gt;
   &lt;/div&gt;
   
  What does RAM stand for?&lt;br&gt;
  1. Random Arithmetic Maths&lt;br&gt;
  2. Random Access Memory&lt;br&gt;
  3. Regional Accounting Money&lt;br&gt;
  Answer 1:
  &lt;input id="RAM" type="number" size="4"&gt;&lt;br&gt;&lt;br&gt;
  What does ADC stand for?&lt;br&gt;
  1. Asynchronous DialUp Call&lt;br&gt;
  2. Active Database Chip&lt;br&gt;
  3. Analog to Digital Converter&lt;br&gt;
  Answer 2:
  &lt;input id="ADC" type="number" size="4" &gt;&lt;br&gt;&lt;br&gt;
  What does AGP stand for?&lt;br&gt;
  1. Active Graphics Pointer&lt;br&gt;
  2. Accelerated Graphics Port&lt;br&gt;
  3. Analog Gateway Protocol&lt;br&gt;
  Answer 3: 
  &lt;input id="AGP" type="number" size="4"&gt;&lt;br&gt;&lt;br&gt;
  What does Laser stand for?&lt;br&gt;
  1. Light and sound emitting range &lt;br&gt;
  2. Light Amplification by Stimulated Emission of Radiation.&lt;br&gt;
  3. Lightening around lithosphere enchanted road &lt;br&gt;
  Answer 4:
  &lt;input id="LAS" type="number" size="4"&gt;&lt;br&gt;&lt;br&gt;
  What does CPU stand for?&lt;br&gt;
  1. Central Processing Unit&lt;br&gt;
  2. Control Primary Unit&lt;br&gt;
  3. Central Personal Unit&lt;br&gt;
  Answer 5: 
  &lt;input id="CPU" type="number" size="4" &gt;&lt;br&gt;&lt;br&gt;
  &lt;button type="button" onClick="QuizFunction()"&gt;Test your answers&lt;/button&gt;
  &lt;br&gt;
  &lt;p id="pstyle"&gt;Number of correct answers&lt;/p&gt;
   
  &lt;script&gt;
  
  function QuizFunction() {
      var ans1 = document.getElementById('RAM').value;
          ans2 = document.getElementById('ADC').value;
          ans3 = document.getElementById('AGP').value;
          ans4 = document.getElementById('LAS').value;
          ans5 = document.getElementById('CPU').value;
          score = 0
  
              function QuizFunction() {
                  if(ans1= 2){var score=score++;
                              document.getElementById('pstyle').innerHTML(score+'/5');}
                  else{document.getElementById('pstyle').innerHTML(score+'/5')}
              }
  }
  
  /**
  function QuizFunction() 
          {
      var ans1 = document.getElementById('RAM').value;
          ans2 = document.getElementById('ADC').value;
          ans3 = document.getElementById('AGP').value;
          ans4 = document.getElementById('LAS').value;
          ans5 = document.getElementById('CPU').value;
          score = 0
  
  
              switch(ans1){
                  case "2":
                       score=score+1
                  default:
                       score=score
              }
              switch(ans2){
                  case "3":
                       score=score+1
                  default:
                       score=score
              }
              switch(ans3){
                  case "3":
                       score=score+1
                  default:
                       score=score
              }
              switch(ans4){
                  case "2":
                       score=score+1
                  default:
                       score=score
              }
              switch(ans5){
                  case "1":
                       score=score+1
                  default:
                       score=score
              }
  
      document.getElementById('pstyle').innerHTML(score+"/5"+"&lt;/br&gt;"+(score/5)*100+"%")
          }
  **/
  
  &lt;/script&gt;
  
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>