Sarah Sarah - 7 months ago 12
Javascript Question

Getting random value from an array

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


How to select random one from this array?

Answer

Simple:

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