title: Dynamic Quiz using JavaScript - add a 'back' button
body: <p>I am an amateur programmer and building a dynamic quiz as part of a beginner course on <a href="http://javascriptissexy.com/how-to-learn-javascript-properly/" rel="nofollow">javascriptissexy's blog</a></p>
  
  <p>I have a bunch of questions stored in an array like this: </p>
  
  <pre><code> var allQuestions = [
  {question: "Which of the following is true about a cat's whiskers?", choices: ["Unlike fur, they don't shed at all", "Defend against predators", "They work as sensors", "They serve no purpose at all"], correctAnswer: 2},
  {question: "How are cats different from dogs?", choices: ["Cats have the ability to move in the air", "Cats are highly social animals", "Dogs are independent but cats are the opposite", "Dogs love children but cats dont"], correctAnswer: 0},
  {question: "What is a sure way of getting a cat's attention if you don't have treats?", choices: ["Call its name", "Stimulate the cat's curiousity", "Cats never pay attention to humans", "Serve some vegetarian food"], correctAnswer: 1},
  ];
  </code></pre>
  
  <p>Choices are set as radio input. Question and choices are displayed one at a time. When the user clicks next, the page displays next set of question and choices in the array. The page does not update if the user clicks next without making a selection - an alert pops up notifying the user to select an option. At the last question, the next button is changed to 'submit' and when the user clicks submit, the total score is displayed.</p>
  
  <p>My problem is that I'm trying to add a 'previous' button so when clicked, the user can view the previous question (up to the first question) along with the selection they made and also be able to change their answer. I'm having a hard time defining the handler function and keeping track of the previous question's answer. Do I need to use a closure by any chance? </p>
  
  <p>Here's a link to my code so far: <a href="http://jsfiddle.net/radha89/ETD95/3/" rel="nofollow"><strong>fiddle</strong></a></p>