I\'ve this function to create a random range of numbers.
function randomRange(min, max) {
return (new Array(++max-min))
.join(\'.\').split(\'.\')
.map(func
According to MDN,
array.sort([compareFunction])
If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other, but sorted with respect to all different elements. Note: the ECMAscript standard does not guarantee this behaviour, and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.
You can try
.sort(function(){ return Math.random()*2-1; })
All you're trying to do here is to return a number that is either greater, less than or equal to 0.