In which scenario would the do-while loop be more appropriate than the while loop in JavaScript?

  • When you want to execute the loop at least once before checking the condition.
  • When you want to skip the loop execution based on a condition.
  • When you want to perform a specific number of iterations.
  • When you want to loop over an array.
The do-while loop in JavaScript is used when you want to execute the loop at least once before checking the condition. This is because the condition is checked after the loop body, ensuring that the loop body is executed at least once. The other options do not describe scenarios where a do-while loop is more appropriate.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *