JS
…

Module 1 of 1

promises

Create promises, chain then/catch, and wait with async/await.

Async JavaScript · 0/7 completed · scroll down for every challenge

Challenge 1 of 7

Resolve a value

Instructions

Write `ok()` that returns a Promise resolving to `"ready"`.

Editor

IntelliSense on

// Write your code below

Challenge 2 of 7 · Then transform

Challenge 2 of 7

Then transform

Instructions

Write `doubleAsync(n)` that resolves n, then doubles it with `.then`.

Editor

IntelliSense on

// Write your code below

Challenge 3 of 7 · Catch error

Challenge 3 of 7

Catch error

Instructions

Write `safe()` that rejects with `"nope"` and returns `"fallback"` via `.catch`.

Editor

IntelliSense on

// Write your code below

Challenge 4 of 7 · Async function

Challenge 4 of 7

Async function

Instructions

Write `async greet()` that returns `"hi"` (use async/await or return the string).

Editor

IntelliSense on

// Write your code below

Challenge 5 of 7 · Await a promise

Challenge 5 of 7

Await a promise

Instructions

Write `async load()` that awaits `Promise.resolve(7)` and returns that number.

Editor

IntelliSense on

// Write your code below

Challenge 6 of 7 · Promise.all

Challenge 6 of 7

Promise.all

Instructions

Write `async total()` that awaits `Promise.all` of 2 and 3, then returns their sum.

Editor

IntelliSense on

// Write your code below

Challenge 7 of 7 · Map async

Challenge 7 of 7

Map async

Instructions

Write `async doubleAll(nums)` that maps each number to a resolved double and uses Promise.all.

Editor

IntelliSense on

// Write your code below

Next module