Skip to content

Instantly share code, notes, and snippets.

View mojtabaasadi's full-sized avatar

Moji mojtabaasadi

  • Shiraz
View GitHub Profile
@arastu
arastu / shuffle.js
Created September 30, 2018 22:49
Shuffle a JavaScript array
Array.prototype.shuffle = function () {
var copy = this.concat()
var currentIndex = copy.length
while (currentIndex !== 0) {
let randomIndex = Math.floor(currentIndex * Math.random())
currentIndex--
let temp = copy[currentIndex]
copy[currentIndex] = copy[randomIndex]