Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Async Double

Asynchronous JavaScripteasy

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

Implement an async function `asyncDouble(n)` that resolves to `n * 2`.

Sample tests

Input: asyncDouble(4)
Output: 8
Input: asyncDouble(0)
Output: 0

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Forgetting async, so the caller cannot await it.

Learning resources

  • MDN: async function
Approach & explanation (try first)

The async function resolves to the doubled value.

Loading...
⌘/Ctrl + Enter

Run your code to see results.