JSFiddle - React, Tailwind, and code Playground

JavaScript

var count = 0;

var assert = function(val,text){
  document.write(text+' '+ val);
}

for ( var i = 0; i < 4; i++ ) {
    document.write(i);  
    setTimeout(
        function(){ 
            assert( i == count++, "Check the value of i." );
        },
        i * 200);
  
}