Javascript Array pick()

Description

Javascript Array pick()


/*global ROT*///from  w w  w .j  a va  2s  .c o  m
Array.prototype.pick = function () {
  'use strict';
  if (!this.length) {
    return null;
  }
  return this.splice(ROT.RNG.getUniformInt(0, this.length), 1)[0];
};

Javascript Array pick()

Array.prototype.pick = function() {
  return this[Math.floor(Math.random()*this.length)];
};



PreviousNext

Related