const knuthShuffle = (arr) => {
  for (let i = 0; i < arr.length; i++) {
    // Generate a random number between 0 and i
    let rnd = Math.floor((Math.random() * (i + 1)));

    // Swap the element in position i with the element in position rnd
    [arr[i], arr[rnd]] = [arr[rnd], arr[i]];
  }

  return arr;
};

console.log(knuthShuffle([1, 2, 3, 4, 5, 6, 7, 8]));

@@ -71,17 +71,24 @@
  %7B%0A    /
-/
+*%0A     *
  Generat
@@ -120,16 +120,284 @@
  0 and i
+.%0A     * IMPORTANT: do not generate a random number between 0 and length, because%0A     * this would generate N%5EN possibilities, whereas a shuffle only has N!%0A     * permutations. Randomizing from 0 to length would result in a biased%0A     * shuffling algorithm.%0A     */
 %0A    let

Add note regarding unbiased shuffles