JSFiddle - React, Tailwind, and code Playground

HTML

<div id="result"></div>

JavaScript

function waitFor(timeout) {
	return new Promise(function(resolve, reject) {
		setTimeout(function() {
			resolve(`Finished waiting ${timeout} milliseconds`);
		}, timeout);
	});
}

waitFor(1000).then(function(resolve, reject) {
	$('#result').append(resolve+' @ '+(new Date().getSeconds())+'<br>');
	waitFor(2000).then(function(resolve, reject) {
		$('#result').append(resolve+' @ '+(new Date().getSeconds())+'<br>');
		waitFor(3000).then(function(resolve, reject) {
			$('#result').append(resolve+' @ '+(new Date().getSeconds())+'<br>');
		});
	});
});