Hi @robmdnnyc
Very well done! I had a look at all three version and you wrote good code.
You could make the second version simpler by removing the return
keyword and the curly braces. This works because when having an arrow function the last statement executed is automatically the return value and when you have only one statement you don’t need curly braces.
alice1.animate(aliceTumbling, aliceTiming).finished
.then(() => alice2.animate(aliceTumbling, aliceTiming).finished)
.then(() => alice3.animate(aliceTumbling, aliceTiming).finished)
.catch(error => console.error(`Error animating Alices: ${error}`));
Version 3 could be made easier because we don’t need the resolved value but just need to wait until the promise is fulfilled (as explained in the other post).
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();
Now that you have coded all three version, I’m interesting in knowing which version do you like the most? Which were you most comfortable with?
Happy coding,
Michael