Skip to main content
Home / Code Snippets / JavaScript / Select Random Item from an Array
var myArray = [
  "Apples",
  "Bananas",
  "Pears"
];

var randomItem = myArray[Math.floor(Math.random()*myArray.length)];

See the Pen gLJPZv by Chris Coyier (@chriscoyier) on CodePen.