JSFiddle - React, Tailwind, and code Playground
by marlanga
HTML
<div id="test"></div>
CSS
div#test {width:100px; height:100px;}
JavaScript
var datos=[["rojo","red"],["verde","green"],["azul","blue"]];
var div = document.getElementById("test");
function cambiar(i){
i=(i+Math.floor(Math.random()*(datos.length-1)+1))%datos.length;
div.style.background=datos[i][1];
div.innerHTML=datos[i][0];
setTimeout(function(){cambiar(i);},1000);
}
cambiar(0);