JSFiddle - React, Tailwind, and code Playground

JavaScript

function wait(ms){
   var start = new Date().getTime();
   var end = start;
   while(end < start + ms) {
     end = new Date().getTime();
  }
  console.log('complete'); //added this so you can see completion order.
}


var wait10 = function() {
	wait(10000);
}

function speak(){
	console.log('Hello World');
}

//call wait10 after one second. This gives time for both setTimeouts to be called before wait10 starts to execute.
setTimeout(wait10,1000);
//call speak after 2 seconds, this means speak would be called while wait10 is executing (albeit quite early). 
setTimeout(speak, 2000);
//Open your console and see what order they complete in.