function shuffle( arr ) {
  // Clone array
  const a = [ ...arr ]

  // Count down from array length
  for ( let i = a.length - 1; i > 0; i-- ) {
    // Get a random element
    const j = Math.floor( Math.random() * ( i + 1 ));
    // Switch 'em up with a destructuring assignment.
    [ a[ i ], a[ j ]] = [ a[ j ], a[ i ]]
  }

  return a
}
/**
 * Shuffles and returns a new array.
 * Hardly the pinnacle of performance, but it'll get the job done.
 * */
Shuffles and returns a new array.
Hardly the pinnacle of performance, but it'll get the job done.
Shuffles and returns a new array . Hardly the pinnacle of performance but it ' ll get the job done .
function shuffle( arr ) {
  const a = [ ...arr ]
  for ( let i = a.length - 1; i > 0; i-- ) {
    const j = Math.floor( Math.random() * ( i + 1 ));
    [ a[ i ], a[ j ]] = [ a[ j ], a[ i ]]
  }
  return a
}
function shuffle ( arr ) { const a = [ ... arr ] for ( let i = a . length - 1 ; i > 0 ; i -- ) { const j = Math . floor ( Math . random ( ) * ( i + 1 ) ) ; [ a [ i ] , a [ j ] ] = [ a [ j ] , a [ i ] ] } return a }
Shuffles and returns a new array.
Shuffles and returns a new array .
// Clone array // Count down from array length // Get a random element // Switch 'em up with a destructuring assignment.