KandZ – Tuts

We like to help…!

JavaScript 11 🧬 Control flow and Conditional execution

a - control flow
Control flow in JavaScript refers to the order in which the code is executed...
and how the execution path can be altered based on certain conditions or statements
Here are some fundamental control structures in JavaScript:
Sequential Execution → Code executes line by line, from top to bottom.
Conditional Statements → Used to execute different blocks of code based on conditions.
Looping Statements → Used to execute a block of code repeatedly.
Break and Continue Statements and return statement

b - conditional execution
conditional execution statements are used to execute different blocks of code based on specific conditions.
These statements help you control the flow of your program based on whether a certain condition is true or false.
The primary conditional execution statements in JavaScript include:
if, else, else if and switch statements
if Statement → Executes code if a condition is true.
else Statement → Provides an alternative block of code when the if condition is false.
else if Statement → Tests multiple conditions sequentially until one evaluates to true.
switch Statement → Evaluates an expression and executes code blocks based on its value.

c - if, else and else if statements
The if statement executes a block of code if a specified condition is true.
The else statement provides an alternative block of code to execute if the condition in the if statement is false.
The else if statement allows for multiple conditional checks. It tests several conditions...
and executes the block of code associated with the first condition that evaluates to true.
if (age = 18) { } → checks if age variable is equal or greater than 18
else { } → alternative execution if previous if statement is false
else if (score = 80) { } → an alternative check to score variable if is equal or grater than 80

Leave a Reply