const first = () => console.log('Hi,i am first');
const second = () => console.log('Hi,i am second');
const third = () => console.log('Hi,i am third');
const fourth = () => {
first();
setTimeout(second, 4000);
//store in queue & it will execute after 4 seconds
setTimeout(third, 2000);
//store in queue & it will execute after 2 seconds
console.log('Hi,i am fourth');
};
fourth();
//Expected output:
/*Hi,i am first
Hi,i am fourth
Hi,i am third
Hi,i am second
*/