Lecture+15+-+JS+Loops+2

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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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 ?
Background image of page 2
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 ?
Background image of page 3

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

View Full DocumentRight Arrow Icon
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 ?
Background image of page 4
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 5

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

View Full DocumentRight Arrow Icon
Image of page 6
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 Right Arrow Icon
Ask a homework question - tutors are online