JSFiddle - React, Tailwind, and code Playground

JavaScript

loopIterate([1, 2, 3], function (element, time) {
    alert(element);
}, 1000);

function loopIterate(array, callback, interval) {
    var start = + new Date;
    process();

    function process() {
        var element = array.shift();
        callback(element, new Date - start);
        array.push(element);

        setTimeout(process, interval);
    }
};