Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Async Identity

Asynchronous JavaScripteasy

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

Implement an async function `asyncIdentity(x)` that resolves to `x`.

Sample tests

Input: asyncIdentity(5)
Output: 5
Input: asyncIdentity("a")
Output: "a"

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Returning a promise of a promise; just return the value.

Learning resources

  • MDN: async function
Visualize this concept: Async/Await →
Approach & explanation (try first)

Marking the function async means returning x resolves to x for the awaiting caller.

Loading...
⌘/Ctrl + Enter

Run your code to see results.