Shuffle array elements
By xyz on 2 weeks ago|0 comment||
0
We all require random data from time to time. But sometimes we need to get random data from a specific dataset.
At that time, we can use the below snippet that will save you time:
const array = [11, 12, 13, 14, 150, 15, 555, 556, 545]
console.log(array.sort(function() {
return Math.random() - 0.5;
}));
// [13, 556, 14, 12, 545, 11, 150, 15, 555]
Add a Comment
Comments
Comments MIA, jokes needed ASAP. Add yours! 😄