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 callback in JavaScript?

View

What is the major drawback of using callbacks in JavaScript?

View

How can you avoid callback hell in JavaScript?

View

In which situation are callbacks commonly used?

View

What does the following code do?

View

How are errors handled in callbacks?

View

Which function accepts a callback function and executes it multiple times?

View

Which of the following is an example of a callback?

View

Which type of callback function is executed only once?

View

What is the second parameter in setTimeout()?

View

What is a callback in JavaScript?

A function that is passed as an argument to another function and is executed after some event or condition
A synchronous function that runs immediately after being called
A function that calls itself recursively
A function that returns another function

What is the major drawback of using callbacks in JavaScript?

Callback functions are slow
Callbacks are not asynchronous
Callbacks can lead to "callback hell" due to nested callbacks
Callbacks cannot be used in modern browsers

How can you avoid callback hell in JavaScript?

By using multiple setTimeout() functions
By using recursion instead of callbacks.
By replacing callbacks with Promises or async/await
By using synchronous code only.

In which situation are callbacks commonly used?

Performing asynchronous operations such as reading files or making network requests.
Running synchronous code in the browser.
Modifying global variables.
Writing CSS code dynamically.

What does the following code do?

setTimeout(function() { console.log("Hello, World!"); }, 1000);

It immediately prints "Hello, World!".
It prints "Hello, World!" after 1000 milliseconds.
It causes an error because setTimeout is not defined.
It prints "Hello, World!" only after the user clicks.

How are errors handled in callbacks?

Using try...catch.
By passing an error object as the first argument in the callback.
Using Promise.all().
By re-calling the function in case of an error.

Which function accepts a callback function and executes it multiple times?

setTimeout()
setInterval()
clearTimeout()
requestAnimationFrame()

Which of the following is an example of a callback?

document.querySelector()
console.log()
setTimeout(function() { alert('Hello!'); }, 2000);
Array.prototype.map()

Which type of callback function is executed only once?

setInterval()
forEach()
setTimeout()
clearTimeout()

What is the second parameter in setTimeout()?

The callback function.
A function to be executed immediately.
The delay in milliseconds.
The interval in milliseconds.