SlideShare a Scribd company logo
1 of 40
   Statements & block
   If Else
   Else If
   Switch
   While Loop
   For loop
   Do while loop
   Break & continue
   Goto & labels
 Expression+; = staement;
 More than one staement is called
  compund staments.

                     Single stament




                    Compund staments
   When a group of statements or
    compund staments protected by open
    and close braces is called block.
             Open brace



                            Block of codes



              Close brace
   Braces surrounded the staments of
    function definition.
                Open brace




                              Function definition




                Close brace
   Braces surround multiple statements
    of loop constructs too.
                 Open brace




                               Loop multiple
                               statements



                 Close brace
   Write a program to take two float
    numbers and do these tasks upon
    them
    ◦   Multiplication
    ◦   Division
    ◦   Subtraction
    ◦   Addition
    ◦   & find remainder
 If – else is used to control the flow with
  the condition.
 In If-Else, if the IF test is true then if
  statements will executes.
 if IF test is false then Else staements will
  execute.
 Be – careful to put open & close braces if
  you have more than one staement in IF
  or ELSE part.
 Here is an example of if-else
 IF test is not true so the else part will
  execute.
   Here we can check as much test as we
    want.
   Each else work will like separate IF.
   All have one else.
   If all test fails then only else part will
    excute.
   As i told we can do any number of tests.
   But it takes hell amount of time. To avoid
    this we will use switch – case.
If (tes-expression)
           True –statement;
Else If (tes-expression)
           True –statement;
Else If (tes-expression)
           True –statement;
Else If (tes-expression)
           True –statement;
Else If (tes-expression)
           True –statement;
Else
           False statement;
Switch (expression){
Case constant-expression:
statement;
Break;
Case constant-expression:
statement;
Break;
Case constant-expression:
statement;
Break;
Case constant-expression:
statement;
Break;
Default: statement;
}
 In switch-case ,we are switching on a
  expression . The expression must be
  integer value. We can do switch
  caseupon string, float or anything else.
 There are more than one case.
 Here we are comparing the case value
  with switch.
 We have a default value if none of case
  satisfies.
   Executing a block of code for a certain no of
    periods.
   We need a condition to test.
   We have to increment or decrement.
   If we have more than one statement then we
    need to put those within curly brace’{}’
   We have three types of loops
    ◦ For loop
    ◦ While loop
    ◦ Do – while loop
   For a loop we need
   Initialized from where you want to start
    ◦ I = 0 or [or any number from where you want]
   Test expression or you can say test
    condition
    ◦ I <= or< or >= or > [certain value]
   Adjustments(increment or decrement)
    ◦ i++
    ◦ i--
 When we don’t use any initializer, test-
  expression & adjustment. The loop
  becomes infinite loop.
 Can we use infinite loop? Yes but with a
  break and a condition.
 The loop will continue infinite until unless
  our condition satisfies. Once condition
  satisfies we will come out using break;
  statement.
 In while loop we have only test-
  expression is tested.
 If expression testing results true then
  the statement or statements executes.
 In do while loop first the statements
  executes
 Next is testing expression
 Here the must run once even the
  expression test id false.
 But in for & while to execute statement
  the expression must be true
 Write all the three programs which I
  showed you on previous slide
  initializing the I value to ‘7’.
 Answer us what you will get and
  when?
 Write a program to display 1 to 100
  using
 For loop
 While loop
 Do-while loop
1.    Write a program to display all odd numbers in
      between 1 to 50.advise
     1.   Use for/while loop
2.    Write a program to display all even numbers in
      between 1 to 50.advise
     1.   Use for/while loop
3.    Write a program to display all numbers in between 1
      to 50 which are less than 26.advise
     1.   Use for/while loop
4.    Write a program to display all numbers in between 1
      to 50 which are greater than 25.advise
     1.   Use for/while loop
 When break occurs it send the
  execution to out of the loop or switch.
 When continue occurs it sends the
  execution right to the testing
  expression.
 These two can be used inside of
  switches and loops
Timesjobs.com
           Click me to hire




Check the links for more informations.
You can put feedback and comments.

More Related Content

Similar to Coding Loops, Conditions and Flow Control in JavaScript

Similar to Coding Loops, Conditions and Flow Control in JavaScript (20)

cpu.pdf
cpu.pdfcpu.pdf
cpu.pdf
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJ
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlan
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
M C6java6
M C6java6M C6java6
M C6java6
 
Loops and iteration.docx
Loops and iteration.docxLoops and iteration.docx
Loops and iteration.docx
 
Do While Repetition Structure
Do While Repetition StructureDo While Repetition Structure
Do While Repetition Structure
 
Control statements
Control statementsControl statements
Control statements
 
UNIT 1- RELATIONAL DATABASE DESIGN USING PLSQL.pdf
UNIT 1- RELATIONAL DATABASE DESIGN USING PLSQL.pdfUNIT 1- RELATIONAL DATABASE DESIGN USING PLSQL.pdf
UNIT 1- RELATIONAL DATABASE DESIGN USING PLSQL.pdf
 
Computer programming 2 Lesson 9
Computer programming 2  Lesson 9Computer programming 2  Lesson 9
Computer programming 2 Lesson 9
 
Computer programming 2 - Lesson 7
Computer programming 2 - Lesson 7Computer programming 2 - Lesson 7
Computer programming 2 - Lesson 7
 
07 flow control
07   flow control07   flow control
07 flow control
 
Control structures IN SWIFT
Control structures IN SWIFTControl structures IN SWIFT
Control structures IN SWIFT
 
Cprogrammingprogramcontrols
CprogrammingprogramcontrolsCprogrammingprogramcontrols
Cprogrammingprogramcontrols
 
C language 2
C language 2C language 2
C language 2
 
Chap3java5th
Chap3java5thChap3java5th
Chap3java5th
 
Chapter 4(1)
Chapter 4(1)Chapter 4(1)
Chapter 4(1)
 
Java Repetiotion Statements
Java Repetiotion StatementsJava Repetiotion Statements
Java Repetiotion Statements
 
Loop and while Loop
Loop and while LoopLoop and while Loop
Loop and while Loop
 
dizital pods session 5-loops.pptx
dizital pods session 5-loops.pptxdizital pods session 5-loops.pptx
dizital pods session 5-loops.pptx
 

Recently uploaded

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 

Recently uploaded (20)

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 

Coding Loops, Conditions and Flow Control in JavaScript

  • 1.
  • 2. Statements & block  If Else  Else If  Switch  While Loop  For loop  Do while loop  Break & continue  Goto & labels
  • 3.  Expression+; = staement;  More than one staement is called compund staments. Single stament Compund staments
  • 4. When a group of statements or compund staments protected by open and close braces is called block. Open brace Block of codes Close brace
  • 5. Braces surrounded the staments of function definition. Open brace Function definition Close brace
  • 6. Braces surround multiple statements of loop constructs too. Open brace Loop multiple statements Close brace
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. Write a program to take two float numbers and do these tasks upon them ◦ Multiplication ◦ Division ◦ Subtraction ◦ Addition ◦ & find remainder
  • 12.  If – else is used to control the flow with the condition.  In If-Else, if the IF test is true then if statements will executes.  if IF test is false then Else staements will execute.  Be – careful to put open & close braces if you have more than one staement in IF or ELSE part.
  • 13.  Here is an example of if-else  IF test is not true so the else part will execute.
  • 14.
  • 15. Here we can check as much test as we want.  Each else work will like separate IF.  All have one else.  If all test fails then only else part will excute.  As i told we can do any number of tests.  But it takes hell amount of time. To avoid this we will use switch – case.
  • 16. If (tes-expression) True –statement; Else If (tes-expression) True –statement; Else If (tes-expression) True –statement; Else If (tes-expression) True –statement; Else If (tes-expression) True –statement; Else False statement;
  • 17.
  • 18. Switch (expression){ Case constant-expression: statement; Break; Case constant-expression: statement; Break; Case constant-expression: statement; Break; Case constant-expression: statement; Break; Default: statement; }
  • 19.  In switch-case ,we are switching on a expression . The expression must be integer value. We can do switch caseupon string, float or anything else.  There are more than one case.  Here we are comparing the case value with switch.  We have a default value if none of case satisfies.
  • 20.
  • 21.
  • 22. Executing a block of code for a certain no of periods.  We need a condition to test.  We have to increment or decrement.  If we have more than one statement then we need to put those within curly brace’{}’  We have three types of loops ◦ For loop ◦ While loop ◦ Do – while loop
  • 23. For a loop we need  Initialized from where you want to start ◦ I = 0 or [or any number from where you want]  Test expression or you can say test condition ◦ I <= or< or >= or > [certain value]  Adjustments(increment or decrement) ◦ i++ ◦ i--
  • 24.
  • 25.
  • 26.  When we don’t use any initializer, test- expression & adjustment. The loop becomes infinite loop.  Can we use infinite loop? Yes but with a break and a condition.  The loop will continue infinite until unless our condition satisfies. Once condition satisfies we will come out using break; statement.
  • 27.
  • 28.  In while loop we have only test- expression is tested.  If expression testing results true then the statement or statements executes.
  • 29.
  • 30.
  • 31.  In do while loop first the statements executes  Next is testing expression  Here the must run once even the expression test id false.  But in for & while to execute statement the expression must be true
  • 32.
  • 33.
  • 34.
  • 35.  Write all the three programs which I showed you on previous slide initializing the I value to ‘7’.  Answer us what you will get and when?
  • 36.  Write a program to display 1 to 100 using  For loop  While loop  Do-while loop
  • 37. 1. Write a program to display all odd numbers in between 1 to 50.advise 1. Use for/while loop 2. Write a program to display all even numbers in between 1 to 50.advise 1. Use for/while loop 3. Write a program to display all numbers in between 1 to 50 which are less than 26.advise 1. Use for/while loop 4. Write a program to display all numbers in between 1 to 50 which are greater than 25.advise 1. Use for/while loop
  • 38.  When break occurs it send the execution to out of the loop or switch.  When continue occurs it sends the execution right to the testing expression.  These two can be used inside of switches and loops
  • 39.
  • 40. Timesjobs.com Click me to hire Check the links for more informations. You can put feedback and comments.