Sarah Sarah - 1 year ago 65
Javascript Question

Getting random value from an array

var myArray = ['January', 'February', 'March'];


How to select random one from this array?

Answer Source

Simple:

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