BeginnerCoder

Lesson 16 — Promise chaining

One step after another

Each .then returns a new Promise holding whatever its callback returned. That means you can chain steps: the next .then receives the previous result. If any step throws, a .catch at the end handles it.

Promise.resolve("ann")
  .then((s) => s.toUpperCase())
  .then((s) => console.log(s)); // ANN

Why it matters: fetch code is usually a chain — get the response, read the JSON, use the data — so you must know how values flow down it.

Want it another way?
Task

Add one more step to the chain so it prints 11 (5 doubled, plus 1).

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.

Keep going with JavaScript Intermediate

Ready for more? Optional paid resources that pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.