If I put this code in the console I get an error on the destructuring line - line 7.
If I put a semi-colon after the console.log line then it works. Js tries to make the code into console.log()[] or something. I wonder if this is indeed an error from the parser or my code.
function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
console.log("i=",i,"j=",j)//error after this line - note no semi-colon.
[array[i], array[j]] = [array[j], array[i]];
}
}
array=[0,1,2,3,4,5
]
shuffleArray(array)
console.log(array)