function getRandomColor() { var ArrColor = ["#ea2121","#8e8e8e","#f9a60e","#18c55d","#4e64ff","#ad3b40"]; alert(ArrColor.lenght); // Выводит undefined var i = Math.floor(Math.random()*ArrColor.lenght); return ArrColor[i]; } getRandomColor()