Javascript get random item from array
snippet in javascript

Javascript get random item from array

user6021

var colors = ["red","blue","green","yellow"];
var randomColor = colors[Math.floor(Math.random()*colors.length)]; //pluck a random color