title: Can't get the correct number of points, dynamic quiz
body: <p>I'm doing a dynamic quiz because I want to learn javascript, jquery, html and css.</p>
  
  <p>My quiz is supposed to add 1 pt to the score variable each time the answer is correct. It seems to work correctly but when I answer the <strong>10 questions correctly its displays 9 correct answers</strong>.</p>
  
  <p>I'll appreciate if someone could help me.</p>
  
  <p>This is my html:</p>
  
  <pre><code>&lt;body&gt;
  &lt;header&gt;
      &lt;hgroup&gt;
          &lt;h1&gt;This is my Dynamic Quiz&lt;/h1&gt;
          &lt;h2&gt;Using html5 / css / javascript&lt;/h2&gt;
      &lt;/hgruop&gt;
  &lt;/header&gt;
  
  &lt;section id='description'&gt;
      &lt;p&gt;This quiz is compossed by 10 questions, you have to answer at least 7 from 10 to pass the exam.&lt;/p&gt;
      &lt;h2&gt;Lets start!&lt;/h2&gt;
  &lt;/section&gt;
  
  &lt;div id='questions-number'&gt;
      &lt;p&gt;Question &lt;span id='current-question'&gt;1&lt;/span&gt; of &lt;span&gt;10&lt;/span&gt; &lt;/p&gt;
  &lt;/div&gt;
  
  &lt;section id='questions'&gt;
      &lt;p id='question'&gt;&lt;/p&gt;
  
      &lt;form id='myForm'&gt;
          &lt;input type='radio' name='quiz' id='0' value='0'/&gt;&lt;label id='answer0'&gt;answer0&lt;/label&gt;&lt;/li&gt;&lt;/br&gt;
          &lt;input type='radio' name='quiz' id='1' value='1'/&gt;&lt;label id='answer1'&gt;answer1&lt;/label&gt;&lt;/br&gt;
          &lt;input type='radio' name='quiz' id='2' value='2'/&gt;&lt;label id='answer2'&gt;answer2&lt;/label&gt;&lt;/br&gt;
          &lt;input type='radio' name='quiz' id='3' value='3'/&gt;&lt;label id='answer3'&gt;answer3&lt;/label&gt;&lt;/br&gt;
      &lt;/form&gt; 
  &lt;/section&gt;
  &lt;div id='score'&gt;&lt;/div&gt;
  &lt;div id='back'&gt;
      back
  &lt;/div&gt;
  &lt;div id='next'&gt;
      next
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>and this is my js file</p>
  
  <pre><code>$(document).on('ready', ready);
  function ready(){
  var allQuestions =
  [
      {
          question: "Whats my real name?",
          choices: ["Jhonnatan", "Alberto", "Tatan","Jaime"],
          answer: 0
      },
  
      {
          question: "Who is Colombia's president?",
          choices: ["Alvaro Uribe", "Andres Pastrana", "Juan Manuel Santos","Tatan"],
          answer: 2
      },
  
      {
          question: "My favorite super heroe?",
          choices: ["Batman", "Flash", "Tatan","Javascript"],
          answer: 3
      },
  
      {
          question: "Wich sports do i practice?",
          choices: ["Climbing", "Swimming", "Programming","Running"],
          answer: 0
      },
  
      {
          question: "Whats my dad's name?",
          choices: ["Alberto", "Jorge", "Javier","Jose"],
          answer: 1
      },
  
      {
          question: "Whats my favorite color?",
          choices: ["Red", "Purple", "Blue","All"],
          answer: 2
      },
  
      {
          question: "My favorite alcoholic drink",
          choices: ["Vodka", "Aguardiente", "Rum","Tekila"],
          answer: 3
      },
  
      {
          question: "Whats my favorite kind of music?",
          choices: ["Hardcore", "Reggaeton", "Salsa","Programming"],
          answer: 0
      },
  
      {
          question: "How many qestions has this quiz??",
          choices: ["20", "8", "10","12"],
          answer: 2
      },
  
      {
          question: "My favorite programming lenguage?",
          choices: ["Ruby", "Arduino", "Python","Javascript"],
          answer: 3
      }
  ];
  
  var score = 0;
  var number=0;
  var question = $('#question');
  var choice1 = $('#answer0');
  var choice2 = $('#answer1');
  var choice3 = $('#answer2');
  var choice4 = $('#answer3');
  var next = $('#next');
  var back = $('#back');
  var currentQuestion = $('#current-question');
  
  next.on('click', changeQuestion);
  addQuestionAndAnswers();    
  back.on('click', backQuestion);
  
  
  
  function addQuestionAndAnswers() {
      currentQuestion.text(number + 1);
      question.text(allQuestions[number].question);
      choice1.text(allQuestions[number].choices[0]);
      choice2.text(allQuestions[number].choices[1]);
      choice3.text(allQuestions[number].choices[2]);
      choice4.text(allQuestions[number].choices[3]);
      console.log('funcionando!');
  }
  
  
  function changeQuestion(){
      if($("#myForm input[type='radio']:checked").length == 1){
          if(number&lt;9){
              if($("#myForm input[type='radio']:checked").val() == allQuestions[number].answer){
                  number = number +1;
                  score ++;
                  addQuestionAndAnswers();
              }else{
                  number = number +1;
                  addQuestionAndAnswers();
              }
          }else{
              displayResult();
      }
          console.log('checked answer');
      }else{
          alert('please select an answer before proceed');
      }
  
  
  
      function displayResult(){
          currentQuestion.text('10');
          $('#myForm').css('display', 'none');
          $('#question').css('display', 'none');
          $('#next').css('display', 'none');
          $('#score').css('display', 'inline-block');
          $('#score').text('Your score is: ' + score + 'pts');
  
  
      }
  }
  
  function backQuestion(){
      if(number &gt; 0){
          number = number -1;
          addQuestionAndAnswers();
      }
  
  
  }
  }
  </code></pre>
  
  <p>[edit]</p>
  
  <p>this is the jsfiddle demo :)</p>
  
  <p><a href="http://jsfiddle.net/xtatanx/Wn8Qg/1/" rel="nofollow">http://jsfiddle.net/xtatanx/Wn8Qg/1/</a></p>