Answers for "shuffle javascipr"

14

js shuffle array

yourArray.sort(function() { return 0.5 - Math.random() });
Posted by: Guest on April-03-2020
1

javascript shuffle an array

const shuffleArray = (arr) => arr.sort(() => 0.5 - Math.random());

console.log(shuffleArray([1, 2, 3, 4]));
// Result: [ 1, 4, 3, 2 ]
Posted by: Guest on September-28-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language