Dynamically add radio buttons
<p>I am trying to make a simple javascript quiz application ,with <code>radio</code> buttons.I've almost finished making the application,but what if I want to add a question to allQuestions array, which has options not equal to 3(for example 2 or 4).
For example, what can I do to remove or add <code>radio</code> buttons depending on the number of options a question has,for instance, question 1 has only 2 options ,but 3 <code>radio</code> buttons &amp; question 2 has 4 options but three <code>radio</code> buttons.
Code:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var allQuestions = [{
    question: "Who is the Prime Minister of the United Kingdom?",
    choices: ["David Cameron", "Gordon Brown"],
    correctAnswer: 0
  },

  {
    question: "Who is the Prime Minister of India?",
    choices: ["Rahul Gandhi", "Arvind Kejrival", "Narendra Damodardas Modi","Dr.Manmohan Singh"],
    correctAnswer: 2
  },

  {
    question: "Who is the Prime Minister of America?",
    choices: ["Donald Trump", "Barack Obama", "Hilary Clinton"],
    correctAnswer: 1
  },

  {
    question: " Who averaged one patent for every three weeks of his life?",
    choices: ["Thomas Edison", "Tesla", "Einstein"],
    correctAnswer: 0
  },

  {
    question: "What continent is cut into two fairly equal halves by the Tropic of Capricorn?",
    choices: ["Africa", "South America", "Australia"],
    correctAnswer: 2
  },

  {
    question: "What explorer introduced pigs to North America?",
    choices: ["Christopher Columbus", "Galileo", "Mussorie"],
    correctAnswer: 0
  },

  {
    question: "What F-word is defined in physics as a “nuclear reaction in which nuclei combine to form more massive nuclei”? ",
    choices: ["Furnace", "Fusion", "Fission"],
    correctAnswer: 1
  },

  {
    question: "What was the first planet to be discovered using the telescope, in 1781?",
    choices: ["Uranus", "Jupiter", "Mars"],
    correctAnswer: 0
  },

  {
    question: "Who is the chief minister of West Bengal, India?",
    choices: ["Buddhadev Bhattacharya", "Jyoti Basu", "Mamta Banerjee"],
    correctAnswer: 2
  },

  {
    question: "Which is the fastest growing religion in the world?",
    choices: ["Islam", "Christianity", "Hinduism"],
    correctAnswer: 0
  }
  /*
   {
    question: "Who is the Prime Minister of America?",
    choices: ["Donald Trump","Barack Obama","Hilary Clinton"],
    correctAnswer:1
   },

   {
    question: "Who is the Prime Minister of America?",
    choices: ["Donald Trump","Barack Obama","Hilary Clinton"],
    correctAnswer:1
   },

   {
    question: "Who is the Prime Minister of America?",
    choices: ["Donald Trump","Barack Obama","Hilary Clinton"],
    correctAnswer:1
   },

   {
    question: "Who is the Prime Minister of America?",
    choices: ["Donald Trump","Barack Obama","Hilary Clinton"],
    correctAnswer:1
   },

   {
    question: "Who is the Prime Minister of America?",
    choices: ["Donald Trump","Barack Obama","Hilary Clinton"],
    correctAnswer:1
   } */
];


$(document).ready(function() {
  var currentquestion = 0;
  var correctAnswers = 0;
  $("#container").hide();
  $('#start').click(function() {
    $("#container").fadeIn();
    $(this).hide();
  });

  $(function() {
    $("#progressbar").progressbar({
      max: allQuestions.length - 1,
      value: 0
    });
  });

  $('#question').html(allQuestions[currentquestion].question);
  $('label[for=option0]').html(allQuestions[currentquestion].choices[0] + "&lt;br/&gt;");
  $('label[for=option1]').html(allQuestions[currentquestion].choices[1] + "&lt;br/&gt;");
  $('label[for=option2]').html(allQuestions[currentquestion].choices[2] + "&lt;br/&gt;");

  $("#next").click(function() {
    if ($("input[name=option]:checked").val() == allQuestions[currentquestion].correctAnswer) {
      correctAnswers++;
    };
    currentquestion++;
    $(function() {
      $("#progressbar").progressbar({
        value: currentquestion
      });
    });
    if (currentquestion &lt; allQuestions.length) {
      $('#question').html(allQuestions[currentquestion].question);
      $('label[for=option0]').html(allQuestions[currentquestion].choices[0] + "&lt;br/&gt;");
      $('label[for=option1]').html(allQuestions[currentquestion].choices[1] + "&lt;br/&gt;");
      $('label[for=option2]').html(allQuestions[currentquestion].choices[2] + "&lt;br/&gt;");
      if (currentquestion == allQuestions.length - 1) {
        $('#next').html("Submit");
        //$('#next').off("click");
        $('#next').click(function() {
          $("#container").hide();
          $("#result").html("Your Score is " + correctAnswers + " out of " + currentquestion + " and your percentage is " + (correctAnswers * 100 / (currentquestion)) + "%").hide();
          $("#result").fadeIn(1500);
        });

      }

    };
  });
});</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>.button {
  display: inline-block;
  padding: 1em;
  background-color: #79BD9A;
  text-decoration: none;
  color: white;
}
body {
  text-align: center;
}
.ui-widget-header {
  background-image: none !important;
  background-color: #FF7860 !important; //Any colour can go here
}
label {
  display: inline-block;
  /*text-align: center;*/
}
h3,
#next {
  text-align: center;
  display: inline-block;
  border-radius: 20%;
}
input[name="option"] {
  float: left;
}
#form div {
  margin: auto;
  max-width: 205px;
}
#progressbar {
  margin: auto;
  margin-top: 20px;
  float: none;
  width: 50%;
  /*height: 100%;*/
}
#container {
  text-align: center;
}
span {
  margin: 5em;
  padding: 3em;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt;
&lt;link href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet" /&gt;
&lt;script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"&gt;&lt;/script&gt;
&lt;body&gt;
&lt;h1&gt;Quiz&lt;/h1&gt;
&lt;a href="#" id="start" class="button"&gt;Let's Begin&lt;/a&gt;
&lt;br/&gt;
&lt;div id="container"&gt;
  &lt;h3 id="question"&gt;&lt;/h3&gt;
  &lt;form id="form"&gt;
    &lt;div&gt;
      &lt;input type="radio" name="option" value="0" id="option0" checked&gt;
      &lt;label for='option0'&gt;&lt;/label&gt;
      &lt;br/&gt;
    &lt;/div&gt;
    &lt;div&gt;
      &lt;input type="radio" name="option" value="1" id="option1"&gt;
      &lt;label for='option1'&gt;&lt;/label&gt;
      &lt;br/&gt;
    &lt;/div&gt;
    &lt;div&gt;
      &lt;input type="radio" name="option" value="2" id="option2"&gt;
      &lt;label for='option2'&gt;&lt;/label&gt;
      &lt;br/&gt;
    &lt;/div&gt;
  &lt;/form&gt;

  &lt;br/&gt;
  &lt;a href="#" id="next" class="button"&gt;Next&lt;/a&gt;
  &lt;br/&gt;
  &lt;div id="progressbar"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div id="result"&gt;&lt;/div&gt;
&lt;/body&gt;</code></pre>
</div>
</div>
</p>

<p>Here is the <a href="https://jsfiddle.net/vLwjzx8o/14/" rel="nofollow">JSFiddle</a></p>