Flashcards
Challenges
← PawWalk Academy
easy
JS ES6+
#63
Promise chain
Prompt
Create a promise chain that:
Fetches a user (simulated: resolve with {id:1, name:'Alice'})
Then fetches their posts (simulated: resolve with ['post1', 'post2']) Log each step. Assign the chain to
const chain
.
Hints
Show
Solution
Show
Your Code
5 min
Reset
Run
function fetchUser() { return Promise.resolve({ id: 1, name: 'Alice' }) } function fetchPosts(userId) { return Promise.resolve(['post1', 'post2']) } // Chain them const chain = fetchUser() // Your code here
Tests
Click Run to test your code