Javascript Array randFromArr()

Description

Javascript Array randFromArr()


//returns random element from array
Array.prototype.randFromArr = function() {
  var a = this[Math.floor(Math.random() * this.length)]
  return a//from   w  w w.  j  ava  2 s .co  m
};

Javascript Array randFromArr()

//returns random element from array
Array.prototype.randFromArr = function() {
  a= this[Math.floor(Math.random() * this.length)]
  console.log(a)//www.j a  v  a2  s  .c o m
  return a
}



PreviousNext

Related