Files
30-seconds-of-code/snippets/randomize-order-of-array.md
Angelos Chalaris 0893f79360 Fibonacci and random
2017-11-30 19:45:56 +02:00

205 B

Randomize order of array

Use sort() to reorder elements, utilizing Math.random() to randomize the sorting.

var randomizeOrder = arr => arr.sort( (a,b) => Math.random() >= 0.5 ? -1 : 1)