Home » JavaScript » JavaScript While Loop » Question

JavaScript While Loop

  1. Consider the following code snippet.
    while (n != 0)
    {
    if (n == 1)
    continue;
    else
    n++;
    }

    What will be the role of the continue keyword in the above code snippet?
    1. The continue keyword breaks out of the loop
    2. The continue keyword restarts the loop
    3. The continue keyword skips the next iteration
    4. The continue keyword skips the rest of the statements in that iteration
    5. None of these
Correct Option: D

Instead of exiting a loop like the break keyword, the continue keyword moves to the next iteration from the place encountered. While the break statement breaks out of the loop.



Your comments will be displayed only after manual approval.