

This would be the bad way to do this as you are blocking b from running until the a function returns. If we need to wait for multiple promises we can wrap them in a Promise.all and then use await prior to the promise keyword. The whole point of the event loop is to avoid blocking code like what is done in the first example. If we use await on each individual function, the JavaScript compiler will wait till the first function is resolved prior to executing the second function. The two examples below display the correct way to utilize an async function. Although we can now make our code look synchronous, it is important to keep in mind that the execution is still asynchronous! This is important to note because you can dramatically increase your execution time if used incorrectly.
