Randomize Field Option Order
Randomize the order of options in a field (e.g. dropdown)
Last updated
Was this helpful?
Randomize the order of options in a field (e.g. dropdown)
Last updated
Was this helpful?
Was this helpful?
/* Randomize array using Durstenfeld shuffle algorithm */
function shuffleArray(array) {
const newArray = [...array];
for (var i = newArray.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = newArray[i];
newArray[i] = newArray[j];
newArray[j] = temp;
}
return newArray;
}
RandomOptions.options = shuffleArray(RandomOptions.options);