Recall & Review
beginner
What keyword is used to declare an async function in JavaScript?
The async keyword is used before the function keyword or before the parentheses in arrow functions to declare an async function.
Click to reveal answer
beginner
What does an async function always return?
An async function always returns a Promise, even if you return a simple value inside it.
Click to reveal answer
beginner
How do you wait for a Promise to resolve inside an async function?
Use the await keyword before the Promise to pause the function execution until the Promise resolves.
Click to reveal answer
beginner
Show the syntax of an async arrow function that returns the string 'Hello'.
const greet = async () => {
return 'Hello';
};Click to reveal answer
beginner
Why use async functions instead of regular functions when working with Promises?
Async functions let you write asynchronous code that looks like normal, synchronous code, making it easier to read and maintain.Click to reveal answer
Which keyword is used to declare an async function?
✗ Incorrect
The async keyword declares an async function.
What does an async function return by default?
✗ Incorrect
Async functions always return a Promise.
How do you pause an async function until a Promise resolves?
✗ Incorrect
The await keyword pauses the async function until the Promise resolves.
Which of these is a correct async function declaration?
✗ Incorrect
The correct syntax is async function functionName() {}.
What is the benefit of using async functions?
✗ Incorrect
Async functions make asynchronous code look like synchronous code, improving readability.
Explain how to declare an async function and how it behaves differently from a regular function.
Think about the keywords and what the function returns.
You got /3 concepts.
Describe how the await keyword works inside an async function.
Consider what happens when you use await before a Promise.
You got /3 concepts.