lundi 1 février 2016

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

I randomize the order of my Array like that :

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 ? Thanks. Nicolas




Aucun commentaire:

Enregistrer un commentaire