Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

pick a random element from an array javascript

var myArray = [
  "Apples",
  "Bananas",
  "Pears"
];

var randomItem = myArray[Math.floor(Math.random()*myArray.length)];
Source by css-tricks.com #
 
PREVIOUS NEXT
Tagged: #pick #random #element #array #javascript
ADD COMMENT
Topic
Name
2+3 =