Write a JS function to shuffle an array.
Write a JS function to shuffle an array.
OR
Given sorted array convert into randomised array.
function randomArray(arr) {
let len = arr.length;
while(len > 0) {
len--;
let random = Math.floor(Math.random() * len);
let temp = arr[len];
arr[len] = arr[random];
arr[random] = temp;
}
return arr;
}
console.log(randomArray([1,2,3,4,5])); ```