mardi 2 février 2016

In jquery, how is it possible to randomize an Array with conditions?

I randomize the order of my array like this:

var arr = [ "A","B","C","D","E","F" ]
arr.sort(function() { return 0.5 - Math.random() });

// produces for example : [ C, E, A, F, D, B ]

But I don't want the "F" in fourth position (for example).

What is the solution ?




Aucun commentaire:

Enregistrer un commentaire