Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Await a Promise

Asynchronous JavaScriptmedium

Course · Section 16: Asynchronous JavaScript: Promises, Async/Await, and AJAX · Lecture 263: Promises and the Fetch API

Implement `resolveAfter(value)` that returns the result of awaiting `Promise.resolve(value)`.

Sample tests

Input: resolveAfter(42)
Output: 42
Input: resolveAfter("x")
Output: "x"

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Returning the promise without awaiting still works for an async function, but the task asks you to await.

Learning resources

  • MDN: Promise
Visualize this concept: The Event Loop →
Approach & explanation (try first)

await unwraps Promise.resolve(value) to the underlying value.

Loading...
⌘/Ctrl + Enter

Run your code to see results.