I have a quiz that has 100+ questions. When the questions load, only 50 of the questions show. The rest are hidden. I am using the following code:
CSS
.question{ display:none; } HTML
<div class="question"> <!-- Code for Each Question --> </div> <!-- Repeat 'question div' for every question. --> JS
var divs = $("div.question").get().sort(function(){ return Math.round(Math.random())-0.5; }).slice(0,50) $(divs).show(); The above code works great, however, instead of just showing 50 questions I would like to show 50 questions in a random order. How would I modify my code to not only show only 50 questions but show them in a random order?
I should note that the above JS was used from another question. I don't fully understand Math.random() and unsure how to randomly display the 50 divs that it does show.
Note: Solution must be pure client side code.