var colors = ['red', 'green', 'blue', 'orange', 'yellow']; myDiv.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)];