JSFiddle - React, Tailwind, and code Playground

HTML

<div id="slider"></div>

CSS

#slider {
  width: 450px;
  height: 200px;
}

JavaScript

var colors = ['red', 'green', 'blue', 'gray', 'orange'],
		delays = [1000, 2000, 3000, 4000],
    i = 0;

(function foo() {
  slider.style.background = colors[i++ % colors.length];

  setTimeout(foo, delays[~~(Math.random() * delays.length)]);
})();