You are on page 1of 4

Previous Assignment (19 January 2022)

Coding:- Output:-

New Assignment (20 January 2022)

“CONTROL FLOW in
javascript”

: What is Control flow ? Also discuss about there types…


Ans: Control Flow:-
The control flow is the order in which the computer executes
statement in a script. JavaScript has two types of control statements
Conditional and Iterative. We learned about conditional statements like IF, IF-
ELSE and SWITCH. And for iterative statements, We learned about WHILE, DO-
WHILE and FOR.

1:- IF.. ELSE:- The if-else statements executes block of code if a specified
condition is true. If the condition is false, another block of statement can be
executed.

Syntax:- if (condition) {
// block of code to be executed if the condition is true
} else {
// block of code to be executed if the condition is false
}

Coding:-

Output:-

2:- Switch Case:- The switch statement executes a block of code depending on
different cases.

Syntax:-
Switch (expression) {
case n1:
statements:
break;
case n2:
statements:
break;
default:
statements:
}

Coding:-
Some confusion about this will discuss in class………

3: FOR LOOP:- A JavaScript for loop executes a block of code as long as a


specified condition is true. JavaScript for loops take three arguments
initialization, condition and increment.
Syntax:-
For (initialization ; condition ; increment/decrement)
{
Body of the loop
}

Coding :- Output:-

You might also like