| 
		
			Сообщение от j0hnik
			
		
	 | 
	| 
		конечно же Math.floor надо
	 | 
	
не обязательно, можно и Math.round - но с Math.floor лучше. а почему вы в курсе? 
<head>
  <meta charset="utf-8">
</head>
<body>
  <div id="id" style="display: block; width: 200px; height: 200px; border: 1px solid grey;"></div>
  <script>
  var rand2;
    document.getElementById("id").onmouseover = function(){
    var color = ['red','green','blue','orange','yellow','violet','cyan']
    var rand = Math.round(Math.random()*color.length-1);
    if (rand2 === rand) rand = ++rand%color.length;
    this.style.backgroundColor = color[rand];
    rand2 = rand;
  };
</script>
</body>