JSFiddle - React, Tailwind, and code Playground

by guyluchenbill

JavaScript

Array.prototype.shuffle = function() { //creates "shuffle" method to Array Prototype 
    
     var len = this.length; //length of an array
    
     var i = len;  // length of the array?
    
     while (i--) { //do while array has a length
          var p = parseInt(Math.random()*len); // create random number based off current index?
          var t = this[i]; //assign a value "t" to the index?
          this[i] = this[p]; //the current index of i is being replaced with the random number p?
          this[p] = t; //random number p is being inserted as current index of i?
     }
};