JSFiddle - React, Tailwind, and code Playground

JavaScript

var counter = 1;
function foo()
{
    alert('Run No. ' +counter);
    if (counter < 5){
        counter++
        window.setTimeout(foo, 400);
    }
}

foo();