1// Tell the browser that this function is asynchronous
2async function myFunc() {
3 // Await for the promise to resolve
4 await new Promise((resolve) => {
5 setTimeout(() => {
6 // Resolve the promise
7 resolve(console.log('hello'));
8 }, 3000);
9 });
10 // Once the promise gets resolved continue on
11 console.log('hi');
12}
13
14// Call the function
15myFunc();