The code below works for a normal array but not with an array with object does anybody knows how to do this?
const array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
function shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
let j = Math.floor(Math.random() * (i + 1));
let temp = array[i];
array[i] = array[j];
array[j] = temp;
}
return array;
}
const result = shuffle(array);
console.log(JSON.stringify(result));