Recall & Review
beginner
What problem do
async and await solve in JavaScript?They help manage asynchronous code in a way that looks and behaves like synchronous code, making it easier to read and write.
Click to reveal answer
beginner
What does the
async keyword do when added before a function?It makes the function return a Promise and allows the use of
await inside it.Click to reveal answer
beginner
How does
await improve code readability?It pauses the function execution until the Promise resolves, so you can write code that looks like normal sequential steps.
Click to reveal answer
intermediate
Why is using callbacks sometimes problematic compared to
async/await?Callbacks can lead to nested code that is hard to read and maintain, often called 'callback hell'.
async/await avoids this by flattening the code structure.Click to reveal answer
intermediate
What happens if you forget to use
await before a Promise inside an async function?The function continues without waiting for the Promise to resolve, which can cause unexpected behavior or errors.
Click to reveal answer
What does the
async keyword do to a function?✗ Incorrect
The async keyword makes the function always return a Promise, allowing use of await inside it.
What is the main benefit of using
await inside an async function?✗ Incorrect
await pauses the function execution until the Promise resolves, making asynchronous code easier to read.
Which problem does
async/await help avoid compared to callbacks?✗ Incorrect
async/await helps avoid callback hell by flattening asynchronous code structure.
If you forget to use
await before a Promise, what happens?✗ Incorrect
Without await, the function does not wait for the Promise, which can cause unexpected results.
Why is asynchronous programming important in JavaScript?
✗ Incorrect
Asynchronous programming prevents blocking the UI, keeping apps responsive during long operations.
Explain why
async and await are useful in JavaScript programming.Think about how they help with waiting for tasks without freezing the program.
You got /4 concepts.
Describe what happens if you use an
async function but forget to use await when calling a Promise inside it.Consider how the function flow changes without waiting.
You got /4 concepts.