Skip to main content

Practice ยท 1 of 2

Await a Sequence

A fake API is provided: api.loadUser() returns a promise resolving to { name: "Ada" }, and api.loadGreeting(name) returns a promise resolving to "Hello, <name>". 1. Write an async function run() that awaits loadUser, then awaits loadGreeting with the user's name, and logs the final greeting. 2. Call run().

Difficulty: intermediate

Back to lesson: Practice: Asynchronous JavaScript: Promises and async/await โ€” Practice