JSFiddle - React, Tailwind, and code Playground

HTML

<div><h1 id="target"></h1></div>

<button id="stop">Stop</button>

CSS

div { font-size:6em }

JavaScript

var arr = [ "one", "two", "three"];
    
(function timer(counter) {
    var text = arr[counter];
    
    $('#target').fadeOut(500, function(){ 
        $("#target").empty().append(text).fadeIn(500);
    });
    
    delete arr[counter];
    arr.push(text);
    
    setTimeout(function() {
        timer(counter + 1);
    }, 3000);
    
    $("#stop").click(function () {
       clearInterval(timer);
    });
        
    
})(0);

setInterval(timer);