Kelompok 8  Java Script : Control Statement II Oleh: Kukuh I. 5108100122 Brian M. 5108100156 Yodiar Hellian  5108100165
Chapter 8 - JavaScript: Control Statements II 1. Introduction 2. Essentials of Counter-Controlled Repetition 3.  For  Repetition Statement 4. Examples Using the  for  Statement 5.  Switch  Multiple-Selection Statement 6.  Do … while  Repetition Statement 7.  Break  and  continue  Statements 8. Labeled  break  and  continue  Statements 9. Logical Operators
1.  Introduction   Continuation of Chapter 8 Theory and principles of structured programming
2.  Essentials of Counter-Controlled Repetition   Counter-controlled repetition Name of a control Initial value Increment or decrement Final value
While Counter.html
3.   for  Repetition Statement   for  repetition statement Handles all the details of counter-controlled repetition for  structure header The first line
3.   for  Repetition Statement for (  var counter=1  ; counter<=7  ; ++counter ) Initial value of control variable Increment control variable Control variable  name Final value of control variable  for which the condition is true for keyword Loop-continuation condition
3.   for  Repetition Statement counter <=  7 document.writeln(  &quot;<p style=\&quot;font-size: &quot; + counter +  &quot;ex\&quot;>XHTML font size &quot; +  counter +  &quot;ex</p>&quot; ); true false var counter =  1 ++counter Establish  initial value of control  variable. Determine  if  final value of control  variable  has been  reached. Body of loop  (this may be many  statements) Increment the control  variable. Fig. 9.4   for  repetition structure flowchart.
For Counter.html
4.  Examples Using the  for  Statement   Summation with  for Compound interest calculation with  for  loop Math  object Method  pow Method  round
Sum.html
Interest.html
5.   switch  Multiple-Selection Statement   Controlling expression Case labels Default case
SwitchTest.html
5.   switch  Multiple-Selection Statement case a case a action(s) true false . . . break case b action(s) break false false case z case z action(s) break default action(s) true true case b
6.   do … while  Repetition Statement   Similar to the  while  statement Tests the loop continuation condition after the loop body executes Loop body always executes at least once
6.   do…while  Repetition Structure condition true action(s) false Fig. 9.10 do … while  repetition statement flowchart.
DoWhile.html
7.   break  and  continue  Statements   break Immediate exit from the structure Used to escape early from a loop Skip the remainder of a  switch  statement continue Skips the remaining statements in the body of the structure Proceeds with the next iteration of the loop
BreakTest.html
ContinueTest.html
8.  Labeled  break  and  continue  Statements   Labeled  break  statement Break out of a nested set of structures Immediate exit from that structure and enclosing repetition structures Execution resumes with first statement after enclosing labeled statement Labeled  continue  statement Skips the remaining statements in structure’s body and enclosing repetition structures Proceeds with next iteration of enclosing labeled repetition structure Loop-continuation test evaluates immediately after the  continue  statement executes
BreakLabelTest.html
ContinueLabelTest.html
9.  Logical Operators   More logical operators Logical AND (  &&  ) Logical OR (  ||  ) Logical NOT (  !  )
9  Logical Operators
9.  Logical Operators
LogicalOperators.html

Kelompok 8 Pbw

  • 1.
    Kelompok 8 Java Script : Control Statement II Oleh: Kukuh I. 5108100122 Brian M. 5108100156 Yodiar Hellian 5108100165
  • 2.
    Chapter 8 -JavaScript: Control Statements II 1. Introduction 2. Essentials of Counter-Controlled Repetition 3. For Repetition Statement 4. Examples Using the for Statement 5. Switch Multiple-Selection Statement 6. Do … while Repetition Statement 7. Break and continue Statements 8. Labeled break and continue Statements 9. Logical Operators
  • 3.
    1.  Introduction Continuation of Chapter 8 Theory and principles of structured programming
  • 4.
    2.  Essentials of Counter-ControlledRepetition Counter-controlled repetition Name of a control Initial value Increment or decrement Final value
  • 5.
  • 6.
    3.   for Repetition Statement for repetition statement Handles all the details of counter-controlled repetition for structure header The first line
  • 7.
    3.   for Repetition Statement for ( var counter=1 ; counter<=7 ; ++counter ) Initial value of control variable Increment control variable Control variable name Final value of control variable for which the condition is true for keyword Loop-continuation condition
  • 8.
    3.   for Repetition Statement counter <= 7 document.writeln( &quot;<p style=\&quot;font-size: &quot; + counter + &quot;ex\&quot;>XHTML font size &quot; + counter + &quot;ex</p>&quot; ); true false var counter = 1 ++counter Establish initial value of control variable. Determine if final value of control variable has been reached. Body of loop (this may be many statements) Increment the control variable. Fig. 9.4 for repetition structure flowchart.
  • 9.
  • 10.
    4.  Examples Using the for Statement Summation with for Compound interest calculation with for loop Math object Method pow Method round
  • 11.
  • 12.
  • 13.
    5.   switch Multiple-Selection Statement Controlling expression Case labels Default case
  • 14.
  • 15.
    5.   switch Multiple-Selection Statement case a case a action(s) true false . . . break case b action(s) break false false case z case z action(s) break default action(s) true true case b
  • 16.
    6.   do …while Repetition Statement Similar to the while statement Tests the loop continuation condition after the loop body executes Loop body always executes at least once
  • 17.
    6.   do…while Repetition Structure condition true action(s) false Fig. 9.10 do … while repetition statement flowchart.
  • 18.
  • 19.
    7.   break and continue Statements break Immediate exit from the structure Used to escape early from a loop Skip the remainder of a switch statement continue Skips the remaining statements in the body of the structure Proceeds with the next iteration of the loop
  • 20.
  • 21.
  • 22.
    8.  Labeled break and continue Statements Labeled break statement Break out of a nested set of structures Immediate exit from that structure and enclosing repetition structures Execution resumes with first statement after enclosing labeled statement Labeled continue statement Skips the remaining statements in structure’s body and enclosing repetition structures Proceeds with next iteration of enclosing labeled repetition structure Loop-continuation test evaluates immediately after the continue statement executes
  • 23.
  • 24.
  • 25.
    9.  Logical Operators More logical operators Logical AND ( && ) Logical OR ( || ) Logical NOT ( ! )
  • 26.
  • 27.
  • 28.