DEV Community

Discussion on: 9 Extremely Powerful JavaScript Hacks

Collapse
 
ygorbunkov profile image
ygorbunkov

The output of #5 (array shuffler) is not that random. I use my own implementation of Fisher-Yates:

const shuffle = arr => arr.reduceRight((r,_,__,s) => (r.push(s.splice(0|Math.random()*s.length,1)[0]), r),[])
Collapse
 
sumnanazadi profile image
Sumnan Azadi

Thak you man, you just saved me a lot of time.