EasyEvent Loop & Promises🐛 Debug Challenge

Missing return in Promise chain drops value

Buggy Code — Can you spot the issue?

Promise.resolve(5)
  .then(n => {
    n * 2;
  })
  .then(n => console.log(n));

Fixed Code

Promise.resolve(5)
  .then(n => {
    return n * 2;
  })
  .then(n => console.log(n));

Bug Explained

Bug: The first .then has no return statement — it returns undefined implicitly. The next .then receives undefined, not 10.

Explanation: Every .then that transforms a value must explicitly return it. Without return, the next handler in the chain receives undefined.

Key Insight: Always return from .then() when you need the value downstream. Missing return is the most common Promise bug.

More Event Loop & Promises Debug Challenges

MediumAsync function result is a Promise — not awaitedMediumSequential awaits for independent operations

Practice spotting bugs live →

38 debug challenges with AI hints

🐛 Try Debug Lab