Answers for "Shuffle an Array Solution js"

14

js shuffle array

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

shuffle an array of numbers in javascript

let numbers = [5, 458 , 120 , -215 , 228 , 400 , 122205, -85411];
numbers = numbers.sort(function(){ return Math.random() - 0.5});
/* the array numbers will be equal for example to [120, 5, 228, -215, 400, 458, -85411, 122205]  */
Posted by: Guest on November-20-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language