Advertisement
Guest User

12321

a guest
Feb 19th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             Array.prototype.random = function(limit)
  2.                     {
  3.                         if (typeof limit == 'undefined' || limit < 0) limit = 1;
  4.                         else if (!limit) limit = this.length;
  5.                         for (var i = 0, source = this, target = new Array(), n = source.length; i < limit && n > 0; i++)
  6.                         {
  7.                             do { var index = Math.random(); } while (index == 1);
  8.                             index = Math.floor(index * n);
  9.                             target.push(source[index]);
  10.                             source[index] = source[--n];
  11.                         }
  12.                         return target;
  13.                     }
  14.                    
  15.                    
  16.                     document.write(new Array(
  17.                    
  18.                     '<img src=emoji/2.png width="200px" height="200px">',
  19.                     '<img src=emoji/3.png width="200px" height="200px">'
  20.  
  21.                     ).random().join(''));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement