Lecture 13

Lecture 13 - -Iteration variable, -Starting point,...

Info iconThis preview shows pages 1–26. Sign up to view the full content.

View Full Document Right Arrow Icon
CS170 Computer Applications for Business Fall 2008 Instructor: Kristian Stout Lecture 13 More Javascript Loops Readings: Chapter 21
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
More Javascript Loops Infinite Loops Nested Loops Interchangeability in loops Two ways to end a loop More loop Examples
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Nested Loops A loop within a loop Steps: - The outside loop is initialized and tested (starts) - Then the inner loop starts, and iterates completely through all of its cycles - Then the outside loop continues
Background image of page 6
Nested Loops Any loop type (for, do or while) can be nested inside any loop type Any number of loops can be embedded Each time you enter a loop from the top (new entry), the loop counter re-initializes Each time you enter a loop from the bottom (repeating), the loop counter continues to increment
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 10
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Interchangeability between loops All loops have the same basic essentials of
Background image of page 12
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 14
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 16
Background image of page 17

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 18
Background image of page 19

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 20
Background image of page 21

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 22
Background image of page 23

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 24
Background image of page 25

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 26
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: -Iteration variable, -Starting point, -Continuation condition and -Increment size So loops can be used interchangeably (usually) -The while and for, always-The do, sometimes Two common ways to stop loops Fixed ending condition End loop when user decides to stop. -eg Use a confirm statement Loops: Advanced Techniques You can affect the loop progress even further then you have seen so far. break;-break allows us to terminate a loop regardless of the termination condition continue;-continue allows us to skip the current iteration of a loop We can nest multiple loop types, as well as use continue; and break; within nested sub-loops we can also continue; just past the inner loops I continued past all the while loops. Only everything up to the confirm got run....
View Full Document

This note was uploaded on 02/07/2011 for the course COMP 178 taught by Professor Stout during the Fall '08 term at Rutgers.

Page1 / 26

Lecture 13 - -Iteration variable, -Starting point,...

This preview shows document pages 1 - 26. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online