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

View

What will the following code output? setTimeout(() => { console.log("Hello!"); }, 1000);

View

Which of the following is a common use of callbacks?

View

What is the purpose of setTimeout?

View

What will this code log? function myFunc(callback) { console.log("Start"); callback(); } myFunc(() => console.log("End"));

View

What does setInterval do in JavaScript?

View

What will this code output? setInterval(() => { console.log("Repeating"); }, 2000);

View

What is the main difference between setTimeout and setInterval?

View

What is the result of this code? function myFunc(callback) { setTimeout(() => { console.log("Async Call"); callback(); }, 1000); } myFunc(() => console.log("Callback executed"));

View

How can you cancel a setTimeout or setInterval?

View

What is a callback function in JavaScript?

A function that is called immediately
A function passed into another function as an argument
A function that calls itself
A function that waits for a delay

What will the following code output? setTimeout(() => { console.log("Hello!"); }, 1000);

"Hello!" immediately
"Hello!" after 1 second
undefined
Error

Which of the following is a common use of callbacks?

Handling synchronous code
Making asynchronous operations like HTTP requests
Looping over arrays
Returning values from functions

What is the purpose of setTimeout?

To run a function immediately
To execute a function after a specified delay
To cancel a function execution
To return a promise

What will this code log? function myFunc(callback) { console.log("Start"); callback(); } myFunc(() => console.log("End"));

Start, End
End, Start
Start
End

What does setInterval do in JavaScript?

Runs a function once after a delay
Repeats execution of a function at specific intervals
Stops the execution of a function
Executes a function immediately

What will this code output? setInterval(() => { console.log("Repeating"); }, 2000);

"Repeating" once
"Repeating" every 2 seconds
"Repeating" after 2 seconds, then stop
Error

What is the main difference between setTimeout and setInterval?

setTimeout executes once, setInterval repeats
setTimeout is synchronous, setInterval is asynchronous
setInterval runs only after the function has finished
setTimeout can’t take callbacks

What is the result of this code? function myFunc(callback) { setTimeout(() => { console.log("Async Call"); callback(); }, 1000); } myFunc(() => console.log("Callback executed"));

Callback executed, Async Call
Async Call, Callback executed
Callback executed
Error

How can you cancel a setTimeout or setInterval?

Using clearTimeout or clearInterval
Using stopTimeout or stopInterval
Using cancelExecution
You cannot cancel them once started