title: Trivia game using jquery
body: <p>I'm creating a trivia game using jquery and javascript. I'm having trouble with the code. I already able to display the first question but now I don't know how to approach the rest of the question. I want the next question and answers to display without needing the user input and continue to display until there is no more question left. Each question have a timer of 30 seconds.</p>
  <pre><code>var userPick;
  
  var correctAnswer = 0;
  
  var incorrectAnswer = 0;
  
  var unAnswer = 0;
  
  var question = 0;
  
  var images;
  
  var count=30;
  
  var disneyQuestion = [{
  question: &quot;In Aladdin, what is the name of Jasmine's pet tiger?&quot;,
  choices: [&quot;Rajah&quot;, &quot;Bo&quot;, &quot;Iago&quot;, &quot;Jack&quot; ],
  images:  [&quot;../images/Rajah.gif&quot;],
  validAnswer: 0
  }, {
  question:&quot;In Peter Pan, Captain Hook had a hook on which part of his     body?&quot;,
  choices: [&quot;Right Foot&quot;, &quot;Left Hand&quot;, &quot;Left Foot&quot;, &quot;Right Hand&quot;],
  validAnswer: 1
  
  }, {
  question:&quot;In the Lion King, where does Mufasa and his family live?&quot;,
  choices: [&quot;Rocky Mountain&quot;, &quot;Forest&quot;, &quot;Desert&quot;, &quot;Pride Rock&quot;],
  validAnswer: 3
  
  }, {
  question:&quot;In Beauty and the Beast, how many eggs does Gaston eat for    breakfast?&quot;,
  choices: [&quot;2 Dozen&quot;, &quot;5 Dozen&quot;, &quot;5000&quot;, &quot;0&quot;],
  validAnswer: 1
  
  }, {
  question:&quot;In Alice in Wonderland, what is the name of Alice’s kitten?&quot;,
  choices: [&quot;Dinah&quot;, &quot;Sammie&quot;, &quot;Kat&quot;, &quot;Luna&quot;],
  validAnswer: 0
  
   }, {
  question:&quot;After being on earth, where did Hercules first meet his   father Zeus?&quot;,
  choices: [&quot;Mount Olympus&quot;, &quot;Greece&quot;, &quot;In the Temple of Zeus&quot;, &quot;Elysian   Fields&quot;],
  validAnswer: 2
  
  }, {
  question:&quot;During the ballroom scene of Beauty &amp; the Beast, what color is Belle’s Gown?&quot;,
  choices: [&quot;Yellow&quot;, &quot;Blue&quot;, &quot;Gold&quot;, &quot;White&quot;],
  validAnswer: 2
  
  }, {
  question:&quot;In Bambi, what word does the owl use to describe falling in love?&quot;,
  choices: [&quot;Whimsical&quot;, &quot;Miserable&quot;, &quot;Joyful&quot;, &quot;Twitterpatted&quot;],
  validAnswer: 3
  
  }
  
  ];
  
  $(&quot;#start_button&quot;).click(function(){
  $(this).hide();
  counter = setInterval(timer, 1000); 
  displayTrivia();
  }); 
  
  
  function timer(){
  count--;
  if (count &lt;= 0) {
   clearInterval(counter);
   return;
  }
  
   $(&quot;#timer&quot;).html(&quot;Time remaining: &quot; + &quot;00:&quot; + count + &quot; secs&quot;);
  }
  
  
  function displayTrivia() {
  $(&quot;#question_div&quot;).html(disneyQuestion[0].question);
  question++;
  
    var choicesArr = disneyQuestion[0].choices;
    var buttonsArr = [];
  
    for (let i = 0; i &lt; choicesArr.length; i++) {
      var button = $('&lt;button&gt;');
      button.text(choicesArr[i]);
      button.attr('data-id', i);
      $('#choices_div').append(button);
     }
  
    } 
  
   $('#choices_div').on('click', 'button', function(e){
   userPick = $(this).data(&quot;id&quot;);
   disneyQuestion[0].validAnswer;
   if(userPick != disneyQuestion[0].validAnswer) {
  
   $('#choices_div').text(&quot;Wrong Answer! The correct answer is Rajah.&quot;);
   incorrectAnswer++;
  
  } else if (userPick === disneyQuestion[0].validAnswer) {
  $('#choices_div').text(&quot;Correct!!! The pet tiger name is Rajah&quot;);
  correctAnswer++;
  
  }
  
  });
  </code></pre>