Skip to content

Instantly share code, notes, and snippets.

@okovalov
Created June 11, 2020 16:05
Show Gist options
  • Select an option

  • Save okovalov/aed6057958bda3e853e8ea92ebd8338d to your computer and use it in GitHub Desktop.

Select an option

Save okovalov/aed6057958bda3e853e8ea92ebd8338d to your computer and use it in GitHub Desktop.

Revisions

  1. okovalov created this gist Jun 11, 2020.
    9 changes: 9 additions & 0 deletions Array_shuffle.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    const shuffle = arr => arr.sort(() => Math.random() - 0.5)

    const data = [1, 2, 3, 4, 5, 6, 7, 8, 9]

    console.log('Data 1', data)
    console.log('Data 2', shuffle(data))
    console.log('Data 3', shuffle(data))
    console.log('Data 4', shuffle(data))
    console.log('Data 5', shuffle(data))