MediumEvent Loop & Promises🐛 Debug Challenge

Async function result is a Promise — not awaited

Buggy Code — Can you spot the issue?

async function getValue() {
  return 42;
}

const result = getValue();
console.log(typeof result);

Fixed Code

async function getValue() {
  return 42;
}

getValue().then(result => console.log(typeof result));

Bug Explained

Bug: async functions always return a Promise. Without await or .then(), result is the Promise object — typeof gives "object", not "number".

Explanation: Chaining .then() unwraps the Promise. Now result inside the callback is the actual number 42.

Key Insight: Calling an async function returns a Promise. You must .then() or await it to get the resolved value.

More Event Loop & Promises Debug Challenges

EasyMissing return in Promise chain drops valueMediumSequential awaits for independent operations

Practice spotting bugs live →

38 debug challenges with AI hints

🐛 Try Debug Lab