DOM Manipulation in JavaScript
15 questions · 12 min · Medium
Test your knowledge of JavaScript control flow and loops, including if-else statements, switch, for, while, do-while, for...of, for...in, break, and continue.
No sign-up needed · Last updated:
Score: 0 00:00
Create a free account to keep your scores and track your progress. It is optional.
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
20 questions · 15 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
A. To control the order in which code is executed
Control flow statements determine which code executes, when it executes, and how many times it executes.
A. if
The if statement executes its block when the specified condition evaluates to true.
A. else
The else statement provides a block that executes when the preceding if condition is false.
A. switch
The switch statement evaluates an expression and executes code associated with a matching case.
A. break
The break statement exits the switch statement and prevents execution from continuing into subsequent cases.
A. for
A for loop combines initialization, a condition, and an update expression in its syntax.
A. while
A while loop evaluates its condition before executing each iteration, so its body may execute zero times.
A. do...while
A do...while loop executes its body first and checks the condition afterward, guaranteeing at least one execution.
A. break
The break statement terminates the nearest enclosing loop or switch statement.
A. Skips the rest of the current iteration and proceeds to the next iteration
The continue statement skips the remaining statements in the current iteration and moves to the next iteration.
A. for...of
The for...of loop iterates over values produced by an iterable, such as the elements of an array.
A. for...in
The for...in loop iterates over enumerable property keys of an object.
A. 0 1 2
The loop starts with i equal to 0 and continues while i is less than 3, so it prints 0, 1, and 2.
A. Ternary operator
The ternary operator uses the form condition ? valueIfTrue : valueIfFalse to choose between two expressions.
A. JavaScript supports conditional statements, switch statements, loops, and branching statements
JavaScript provides several control flow mechanisms, including if-else, switch, for, while, do...while, for...of, for...in, break, and continue.