Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

What is a promise in JavaScript?

View

What are the states of a promise?

View

Which method is used to handle the resolved value of a promise?

View

How do you handle errors in a promise chain?

View

Which of the following correctly uses async and await?

View

What is the purpose of the async keyword?

View

What happens when you use await with a non-promise value?

View

What is the result of this code: async function foo() { return 10; } console.log(foo());?

View

How do you wait for multiple promises to resolve simultaneously?

View

What is the correct syntax to catch an error in an async function?

View

What is a promise in JavaScript?

A function that always resolves
An object representing the eventual completion or failure of an asynchronous operation
A method for handling synchronous code
A class for creating objects

What are the states of a promise?

Pending, Fulfilled, Failed
Started, Finished, Error
Pending, Fulfilled, Rejected
Active, Completed, Failed

Which method is used to handle the resolved value of a promise?

resolve()
catch()
then()
await()

How do you handle errors in a promise chain?

Using the then() method
Using the resolve() method
Using the reject() method
Using the catch() method

Which of the following correctly uses async and await?

async function foo() { await bar(); }
function foo() await bar();
async function foo() { await bar(); then(); }
await function foo() { bar(); }

What is the purpose of the async keyword?

It pauses a function
It turns a function into an asynchronous function
It creates a promise chain
It signals an error in the function

What happens when you use await with a non-promise value?

It returns a rejected promise
It throws an error
It wraps the value in a promise and resolves it
It causes a syntax error

What is the result of this code: async function foo() { return 10; } console.log(foo());?

10
Promise { <resolved>: 10 }
undefined
It throws an error

How do you wait for multiple promises to resolve simultaneously?

Promise.race()
Promise.all()
async.all()
Promise.await()

What is the correct syntax to catch an error in an async function?

try { await foo(); } catch(e) { console.log(e); }
await foo().catch(e => console.log(e));
Both a and b
None of the above