Is there a way to sort a JavaScript array in a random order kind of like this:
var string1 = [0,1,2,3,4,5,6,7,8,9];
var string2 = [
string1[math.floor(math.random() * 6)],
string1[math.floor(math.random() * 6)],
string1[math.floor(math.random() * 6)],
string1[math.floor(math.random() * 6)],
string1[math.floor(math.random() * 6)],
string1[math.floor(math.random() * 6)],
string1[math.floor(math.random() * 6)],
string1[math.floor(math.random() * 6)],
string1[math.floor(math.random() * 6)],
string1[math.floor(math.random() * 6)]
];
document.write(
string2[0] +
string2[1] +
string2[2] +
string2[3] +
string2[4] +
string2[5] +
string2[6] +
string2[7] +
string2[8] +
string2[9] );
Is there any way to do that but without any numbers repeating or doing an if/else statement for each possible combination saying if they are equal change it?