Hi @jordanmichele61 and welcome to the community
Congratulations! You correctly solved the exercise. We could make the code a bit simpler because we don’t need the return value of the await calls. A minimal solution looks like this:
async function animateAlices() {
try {
await alice1.animate(aliceTumbling, aliceTiming).finished;
await alice2.animate(aliceTumbling, aliceTiming).finished;
await alice3.animate(aliceTumbling, aliceTiming).finished;
}
catch (error) {
console.error(`Error animating Alices: ${error}`);
}
}
animateAlices();
This question feels a bit too broad to be clearly answered. In general you’ll use async calls to fetch or send data from/to a server. That’s an operation that could take some time and you don’t want the rest of your application being blocked unit the response from the server arrives. The perfect use case for such non-blocking async functions.
For example this is a async function in my current code that gets some “types” from the server and if the operation was successful returns those types in an array or in the case of an error returns null
. While the application waits for an answer from the server other stuff in the app can still happen.
async getTypes () {
try {
const response = await http.get('adminModule.cfc?method=getTypes')
return response.data.types
} catch (error) {
return null
}
}
I hope that makes it a bit clearer.
See you,
Michael