Challenge - 5 Problems
Async Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this synchronous code?
Consider the following JavaScript code snippet. What will be printed to the console?
Javascript
console.log('Start'); console.log('Middle'); console.log('End');
Attempts:
2 left
💡 Hint
Synchronous code runs line by line in order.
✗ Incorrect
All console.log statements run one after another in the order they appear, so the output is Start, then Middle, then End.
❓ Predict Output
intermediate2:00remaining
What is the output of this asynchronous code with setTimeout?
Look at this JavaScript code using setTimeout. What will be printed to the console and in what order?
Javascript
console.log('First'); setTimeout(() => console.log('Second'), 0); console.log('Third');
Attempts:
2 left
💡 Hint
setTimeout with 0 delay runs after the current call stack is empty.
✗ Incorrect
The synchronous console.log('First') runs first, then console.log('Third'). The setTimeout callback runs last, even with 0 delay.
❓ Predict Output
advanced2:00remaining
What is the output of this Promise-based asynchronous code?
Analyze this JavaScript code using Promises. What will be printed to the console and in what order?
Javascript
console.log('A'); Promise.resolve().then(() => console.log('B')); console.log('C');
Attempts:
2 left
💡 Hint
Promise.then callbacks run after the current synchronous code but before setTimeout callbacks.
✗ Incorrect
The synchronous logs 'A' and 'C' run first. The Promise.then callback runs after, printing 'B'.
❓ Predict Output
advanced2:00remaining
What error does this asynchronous code cause?
What error will this JavaScript code produce when run?
Javascript
setTimeout(() => { console.log(x); }, 10); let x = 5;
Attempts:
2 left
💡 Hint
Variables declared with let are hoisted but not initialized until their declaration line.
✗ Incorrect
The setTimeout callback runs after 10ms, by which time x is initialized to 5, so it prints 5.
🧠 Conceptual
expert2:00remaining
Which option best describes the JavaScript event loop behavior?
Choose the correct statement about how JavaScript handles synchronous and asynchronous code execution with the event loop.
Attempts:
2 left
💡 Hint
Remember the order: synchronous code, then microtasks, then macrotasks.
✗ Incorrect
JavaScript runs all synchronous code first, then microtasks (like Promise callbacks), then macrotasks (like setTimeout callbacks).