title: counting unexpectedly increased by 2 in 2nd attempt, while i coded it to just increment by 1?
body: <p>I wrote this jQuery code to generate words memory quiz. Everything is working fine except for the variable <code>nq</code>.
  In the first attempt, the code simply generates 3 words. After the user has guessed the correct word, it goes on for another trial in which it generates 4 words. </p>
  
  <p>However, in the third trial it unexpectedly generates 6 words instead of 5. I am unable to find the mistake. Can someone help?</p>
  
  <pre><code>$(document).ready(function (){
   // var arr is used to store temporary words generated in quiz
   var arr=[];
   // var t is used to ask question and match result using arr array
   var t;
   // var nq is used to set number of question in each attempt. this variable not functioning right
   var nq=2;
   function arraysave(i,data){
       arr[i]=data;
   }
   function arrayclear(){
       arr=[];
   }
   function question(data){
       t = data;
   }
   function nqplus(){
       nq++;
   }
   function nqdef(){
       nq=2;
   }
   alert("Please leave a like if you like this game and comment your review if any");
   $("#startgame").click(function(){
   $("#firstpage").slideUp(1000);
   $("#secondpage").slideDown(1000);
   });
   $("#startgen").on('click',function(){
   // stored words here in variable strings
        var strings = ["apple","mango","peach","banana","orange","grapes","watermelon","tomato", "blackberry","blueberry", "chips", "bottle", "doubt", "class", "school", "country", "ocean", "foot", "hand", "hair", "mobile", "phone", "great", "sololearn", "love", "help", "sad", "bad", "good", "bottle", "neck", "laptop", "printer", "program", "relation", "ship", "true", "false", "query", "hate", "game", "guess", "name", "future", "present", "past", "city", "alone", "party"];
  var count=-1;
  $("#startgen").hide();
   //this function generate a word every second in quiz
  var i = setInterval(function (){
  count++;
  var output = strings[Math.floor(Math.random() * strings.length)];
      arraysave(count,output);
      $("#words").text((count+1)+"="+output);
      if(count==nq){clearInterval(i);
          setTimeout(function(){ $("#words").text("Now click Next");$("#next").show()}, 1000);
  
      }
  },1000);
   });
   $("#nextfinal").on('click',function(){
       $("#secondpage").slideUp(1000);
       $("#thirdpage").slideDown(1000);
    //setting here variable t to ask question e.g. what word came at place 3
        var t = Math.floor(Math.random() * (nq+2));
        if(t&lt;1){
            t=1;
        }
        if(t&gt;(nq+1)){
            t=(nq+1);
        }
        question(t);
        $("#question").text("Which word came at place "+t);
        });
   //below function works when user submit his answer after filling a text box
        $("#submit").on('click',function(){
            var temp= $("#wordbox").val();
            if(temp==arr[(t-1)]){
                $("#thirdpage").slideUp(1000);
                $("#res").slideDown(1000);
                $(".result").text("you win");
                $("#nextlevel").on('click',function(){
                   nqplus();
                   arrayclear();
                   $("#res").slideUp(1000);
                   $("#secondpage").slideDown(1000);
                   $("#words").text("Focus Here");
                   $("#next").hide();
                   $("#startgen").show();
                });
            }
            else{
                $("#win").show();
                 $(".result").text("you loose");
            }
        });
  });
  </code></pre>