Javascript Developer JSE 40 01 · Free Practice Question Medium

Question 9

Q122 - Control Flow


Which of the following loop instructions checks

the loop continuation condition only after the iteration has been completed?


  • A

    while

  • B

    for ... in

  • C

    do ... while

  • D

    for

Reveal correct answer

Correct answer: C

Explanation

Topic: do while


Try it yourself:


Explanation:

The do while is used when you want to run a code block at least one time.

https://www.w3schools.com/jsref/jsref_dowhile.asp


Q122 (Please refer to this number, if you want to write me about this question.)

A. The while loop in JavaScript checks the loop continuation condition before each iteration, not after the iteration has been completed. It is used when the number of iterations is not known beforehand, and the loop will continue as long as the condition is true.

B. The for...in loop in JavaScript is used for iterating over the properties of an object. It does not check the loop continuation condition after the iteration has been completed; instead, it iterates over the enumerable properties of an object.

C. The do...while loop in JavaScript is unique in that it checks the loop continuation condition after the iteration has been completed. This means that the loop body will always execute at least once before the condition is checked for continuation.

D. The for loop in JavaScript checks the loop continuation condition before each iteration, not after the iteration has been completed. This loop structure is commonly used for iterating over a range of values or elements in an array.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need