1const asyncOperation = () => {
2 return new Promise((resolve, reject) => {
3 setTimeout(()=>{resolve("hi")}, 3000)
4 })
5}
6
7const asyncFunction = async (callback) => {
8 let res = await asyncOperation();
9 callback(res);
10}
11
12const topDog = () => {
13 let callback = (res) => {
14 console.log(res);
15 };
16
17 (async () => {
18 await asyncFunction(callback)
19 })()
20}
21