Q
What is the purpose of the following JavaScript statement? continue;

Answer & Solution

Answer: Option B
Solution:
The continue; statement is used to skip the current iteration in a loop and continue to the next iteration. When encountered, it immediately stops the current iteration and jumps to the next iteration in the loop block.
Related Questions on Average

What is the purpose of the following JavaScript statement? return result;

A). Exits the current loop or switch statement

B). Skips the current iteration in a loop

C). Exits the current function and returns a value

D). Continues to the next iteration in a loop

What will be the output of the following JavaScript code? Code: let x = 15; if (x > 10) { console.log('x is greater than 10'); } else { console.log('x is not greater than 10'); }

A). x is greater than 10

B). x is not greater than 10

C). Undefined

D). Error

What does the following JavaScript code snippet do? Code: let num = 5; while (num > 0) { console.log(num); num--; }

A). Declares a variable and assigns a value to it

B). Executes a block of code repeatedly until a condition becomes false

C). Calculates the sum of numbers from 1 to 5

D). Checks if a number is positive or negative

What will be the output of the following JavaScript code? Code: let i = 1; do { console.log(i); i++; } while (i < 3);

A). 1 2 3

B). 1 2 3 4

C). 2 3 4

D). Infinite loop

What will be the output of the following JavaScript code? Code: let x = 10; while (x > 0) { console.log(x); x -= 2; }

A). 10 8 6 4 2 0

B). 10 8 6 4 2

C). 8 6 4 2 0

D). 9 7 5 3 1 -1

What will be the output of the following JavaScript code? Code: let count = 0; do { console.log(count); count++; } while (count < 3);

A). 0 1 2 3

B). 0 1 2

C). 1 2 3

D). Infinite loop

What does the following JavaScript code snippet do? Code: let numbers = [1, 2, 3, 4, 5]; for (let i = 0; i < numbers.length; i++) { console.log(numbers[i]); }

A). Prints all elements of the array numbers

B). Calculates the sum of elements in the array numbers

C). Finds the maximum element in the array numbers

D). Checks if all elements in the array numbers are even

What will be the output of the following JavaScript code? Code: for (let i = 0; i <= 3; i++) { console.log(i); }

A). 0 1 2 3

B). 0 1 2

C). 1 2 3

D). 1 2 3 4

Which of the following JavaScript statements is used to execute a block of code repeatedly while a condition remains true?

A). Function invocation statement

B). Conditional statement (if statement)

C). Assignment statement

D). Looping statement (while loop)

What does the following JavaScript code snippet do? Code: let x = 10; if (x % 2 === 0) { console.log('Even'); } else { console.log('Odd'); }

A). Checks if x is even and prints 'Even'

B). Checks if x is odd and prints 'Odd'

C). Checks if x is greater than 0 and prints 'Positive'

D). Checks if x is less than 0 and prints 'Negative'