JSFiddle - React, Tailwind, and code Playground

by Jonatas Piazzi

JavaScript

function returnDelay(x) {
	return new Promise((resolve, reject) => {
  	setTimeout(() => {
    	reject();
		}, 1000);
	})
}

async function add(v1, v2) {
	var a = returnDelay(v1);
  var b = returnDelay(v2);
  
  return await a + await b;
}

add(10, 20).then(v => console.log("value ", v));

(() => {
	var count = 0;
  var time = setInterval(() => {
  	count += 10;
    
    if (count % 200 == 0) {
    	console.log('Passed', count, 'milliseconds');
    }
    
    if (count > 4000) {
    	clearInterval(time);
    }
  }, 10);
})();