Comment

Comment by threatofrain

Slightly challenging one. Find the potential bug.

   const arr = [1, 2, 3, 4, 5]

   for (let i = arr.length - 1; 0 < i; i--) {
      const j = Math.floor(Math.random() * (i + 1))
      [arr[i], arr[j]] = [arr[j], arr[i]]
   }

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton