JSFiddle - React, Tailwind, and code Playground
by nnnnnn
HTML
<p id="notice"></p>
JavaScript
function changeColors(colors, repeats) {
var i = 0;
if (typeof repeats === "undefined")
repeats = 1;
function doNext() {
if (i >= colors.length){
if (--repeats > 0)
i = 0;
else
return;
}
$('body').css('background-color', colors[i].color);
setTimeout(doNext, colors[i++].delay);
}
doNext();
}
changeColors([{color : "gold", delay : 800},
{color : "red", delay : 200},
{color : "blue", delay : 400}],
3);