JSFiddle - React, Tailwind, and code Playground

JavaScript

for (var i = 0; i < 3; i++) {
	setTimeout(function() {
    	var logNode = createLogNode("First example: " + i);
    	document.body.appendChild(logNode);
    }, 0);
}

[1, 2, 3].forEach(function(i) {
	setTimeout(function() {
    	var logNode = createLogNode("Second example: " + i);
    	document.body.appendChild(logNode);
    }, 0);
});

function createLogNode(text) {
	var node = document.createElement("div");
    node.textContent = text;
    return node;
}