Control and Loop - refer to essential elements of programming that developers to manage the flow of a program and execute tasks efficiently.
JavaScriptControl - used to control the execution of a program based on a specific condition. If the condition is met, then a particular block of action will be executed otherwise it will execute another block of action that satisfies that particular condition.
JavaScript includes if/else conditional statements to control the program flow.
JavaScript If/Else Statements:
If Statement
If Else Statement
Else If Statement
IfCondition - use if conditional statement if you want to execute something based on some condition.
ElseCondition - use this statement when you want to execute the code whenever the condition evaluates to false.
ElseIfCondition - use this condition when you want to apply second level condition after if statement.
SwitchStatement - is used for decision-making. It evaluates an expression, matches the expression's value against a series of case clauses, and executes the statements associated with the matching case.
JavaScriptLoop - are powerful tools for performing repetitive tasks efficiently. They execute a block of code again and again while the condition is true. They are used to execute a block of code repeatedly based on a condition.
JavaScript Loop Statements:
For Loop
While Loop
Do While Loop
ForLoop - used when the number of iterations is known before entering the loop.
WhileLoop - used when the number of iterations is not known beforehand. It continues to execute as long as the specified condition is true.
DoWhileLoop - is similar to the while loop, but it guarantees that the code block is executed at least once before checking the condition.