Lecture+15+-+JS+Loops+2

# Lecture+15+-+JS+Loops+2 - CS170Lecture13 JSLoopspart2...

This preview shows pages 1–6. Sign up to view the full content.

CS 170 Lecture 13 JS Loops part 2 Kristian Stout [email protected] Office IN: Livingston Student Center, A lounge near “the rock” and the commuter lounge. Office Hours: TTH 5:30 – 6:30

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

View Full Document
Infinite Loops Fixing the code to avoid an infinite loop: var continueLoop = true; while( continueLoop ) { document.write( “I am getting dizzy.<br>”); continueLoop = confirm(“Do you want to continue?”); } How do we fix this code ?
Fixing the code to avoid an infinite loop: var i = 1; do { document.write( “Ack! I am still getting dizzy!”); i++; } while( i <= 2 ); How do we fix this code ?

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

View Full Document
Fixing the code to avoid an infinite loop: for( i=0; i<10; i++ ) { document.write( “This is line ” + i + “<br>” ); } How do we fix this code ?
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

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/17/2011 for the course BUSINESS 198:170 taught by Professor Staff during the Spring '09 term at Rutgers.

### Page1 / 24

Lecture+15+-+JS+Loops+2 - CS170Lecture13 JSLoopspart2...

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

View Full Document
Ask a homework question - tutors are online