Select Random Item from an Array

Chris Coyier on
var myArray = [ "Apples", "Bananas", "Pears" ]; var randomItem = myArray[Math.floor(Math.random()*myArray.length)];

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