Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Shuffle The Array

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

console.log(shuffleArray([1, 2, 3, 4]));
// Result: [ 1, 4, 3, 2 ]
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #Shuffle #The #Array
ADD COMMENT
Topic
Name
3+5 =