I'm trying to modify this quiz app from a tutorial from Awais Mirza
I would like to pick a random selection of questions from a master array and push it in to a selection array the script uses to populate questions, so the quiz will give a random set of questions form the master array every time the quiz is run. I thought i could use Fisher-Yates shuffle to randomize the master array before pushing the selected number of questions into a selection array.
Why does the Fisher-Yates shuffle work with this array;
var arr = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
var i = arr.length, j, temp;
while(--i > 0){
j = Math.floor(Math.random()*(i+1));
temp = arr[j];
arr[j] = arr[i];
arr[i] = temp;
}
console.log(arr);
but not with this array?
var Questions = [
new Question("What comes after 1?", ["1", "2","3", "4"], "2"),
new Question("What comes after 2?", ["1", "2", "3", "4"], "3"),
new Question("What comes after 3?", ["1", "2", "3", "4"], "4")
];