STATEMENT’S AND LOOP’S
DEFINATION AND EXAMPLES
BY BILAL AHMED
STATEMENT’S
JavaScript support four decision making statements which are as
follows:
If
If-else
If-else if
switch
IF STATEMENT
If statement executes a block of
statement based on a logical
Boolean condition.
• if this condition is true the
block following the statement
is executed.
• If the condition is false the
block after the if statement is
not executed and after
statement block is executed.
IF-ELSE STATEMENT
Sometime If is required to
define a block of statement to
be executed when a condition is
evaluated to false. This is done
using the if-else statement.
if else statement begins with the
If Block which is followed by the
else block
IF-ELSE IF STATEMENT
If else statement allows you to check
multiple condition and specify a different
block to be executed for each condition.
The flow of these statements begins with
the If statement followed by multiple else
If statement and finally by an optional
else block
If the condition in the If statement is false
the condition in the immediate else If
statement is evaluated
SWITCH-CASE STATEMENT
A program becomes quite
difficult to understand when
they are multiple if statements
to simplify coding Switch-case
statement is used.
This statement allows
comparing a variable or
expression with multiple values.
LOOP’S
JavaScript supports Three Types of loops that are as follows:
While Loop
For Loop
Do-while Loop
WHILE LOOP
The while loop executes a block
of code as long as the given
condition remains true.
The while loop begins with while
keyword which is followed by
parentheses containing a
Boolean condition.
FOR LOOP
The for loop is similar to while
loop in functionality It executes
the statements within the loop
as long as the given condition is
true.
Unlike while loop the for loop
specifies the loop control
statements at the top instead in
the body of the loop.
DO-WHILE LOOP
The do-while loop is similar to
while loop This is because both
the do-while and while loops
execute until the condition
becomes false.
However the do-while loop
executes the body of loop at
least once before evaluating the
condition.
STATEMENT’S AND LOOP’S

STATEMENT’S AND LOOP’S

  • 1.
    STATEMENT’S AND LOOP’S DEFINATIONAND EXAMPLES BY BILAL AHMED
  • 2.
    STATEMENT’S JavaScript support fourdecision making statements which are as follows: If If-else If-else if switch
  • 3.
    IF STATEMENT If statementexecutes a block of statement based on a logical Boolean condition. • if this condition is true the block following the statement is executed. • If the condition is false the block after the if statement is not executed and after statement block is executed.
  • 4.
    IF-ELSE STATEMENT Sometime Ifis required to define a block of statement to be executed when a condition is evaluated to false. This is done using the if-else statement. if else statement begins with the If Block which is followed by the else block
  • 5.
    IF-ELSE IF STATEMENT Ifelse statement allows you to check multiple condition and specify a different block to be executed for each condition. The flow of these statements begins with the If statement followed by multiple else If statement and finally by an optional else block If the condition in the If statement is false the condition in the immediate else If statement is evaluated
  • 6.
    SWITCH-CASE STATEMENT A programbecomes quite difficult to understand when they are multiple if statements to simplify coding Switch-case statement is used. This statement allows comparing a variable or expression with multiple values.
  • 7.
    LOOP’S JavaScript supports ThreeTypes of loops that are as follows: While Loop For Loop Do-while Loop
  • 8.
    WHILE LOOP The whileloop executes a block of code as long as the given condition remains true. The while loop begins with while keyword which is followed by parentheses containing a Boolean condition.
  • 9.
    FOR LOOP The forloop is similar to while loop in functionality It executes the statements within the loop as long as the given condition is true. Unlike while loop the for loop specifies the loop control statements at the top instead in the body of the loop.
  • 10.
    DO-WHILE LOOP The do-whileloop is similar to while loop This is because both the do-while and while loops execute until the condition becomes false. However the do-while loop executes the body of loop at least once before evaluating the condition.