Wednesday, November 2, 2016

javascript random array

function randcol() {
var ac =["red","orange","yellow","green","blue","purple","brown","pink","magenta","cyan","olive","maroon","navy","aquamarine","turquoise","silver","lime","teal","indigo","violet"]
return ac[Math.floor(Math.random() * ac.length)]
}

//test call

console.log( randcol())

See the Pen NbKXYV by Usman Fauzi (@flint002) on CodePen.

No comments: