Sarah Sarah - 1 year ago 80
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)];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download