Loops Kevin Harville for loops for my Var
![Loops Kevin Harville Loops Kevin Harville](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-1.jpg)
![for loops for (my. Var = 1; my. Var<=10; my. Var + 2){ alert(my. for loops for (my. Var = 1; my. Var<=10; my. Var + 2){ alert(my.](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-2.jpg)
![while loops while (condition == true){ alert("True"); //maybe the condition changes } While loops while loops while (condition == true){ alert("True"); //maybe the condition changes } While loops](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-3.jpg)
![while loops //previous statements … while (condition == true){ alert("True"); } //subsequent statements… The while loops //previous statements … while (condition == true){ alert("True"); } //subsequent statements… The](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-4.jpg)
![do while loops do { alert("True") //maybe the condition changes } while (condition == do while loops do { alert("True") //maybe the condition changes } while (condition ==](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-5.jpg)
![Breaking out while (condition == true){ alert("True"); if (tired == true) break; } //subsequent Breaking out while (condition == true){ alert("True"); if (tired == true) break; } //subsequent](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-6.jpg)
![continue var x = 5; while (x < 10) { x++; if (x == continue var x = 5; while (x < 10) { x++; if (x ==](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-7.jpg)
![for … in loops Similar to the previous but cycle through all properties of for … in loops Similar to the previous but cycle through all properties of](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-8.jpg)
![Loops and Arrays ® Loops are very often used with arrays. ® Remember, arrays Loops and Arrays ® Loops are very often used with arrays. ® Remember, arrays](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-9.jpg)
![Looping through an Array for (i=0; i <= 2; i++) { alert(my. Array[i]) } Looping through an Array for (i=0; i <= 2; i++) { alert(my. Array[i]) }](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-10.jpg)
![Putting it all together: my. Array = new Array(); my. Array[0] = 24 my. Putting it all together: my. Array = new Array(); my. Array[0] = 24 my.](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-11.jpg)
![Summary of Loops ® for loop ® while loop ® do / while loop Summary of Loops ® for loop ® while loop ® do / while loop](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-12.jpg)
- Slides: 12
![Loops Kevin Harville Loops Kevin Harville](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-1.jpg)
Loops Kevin Harville
![for loops for my Var 1 my Var10 my Var 2 alertmy for loops for (my. Var = 1; my. Var<=10; my. Var + 2){ alert(my.](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-2.jpg)
for loops for (my. Var = 1; my. Var<=10; my. Var + 2){ alert(my. Var) } ® Loop, through the braced code starting with my. Var at 1. ® Continue as long as my. Var is <= 10 ® Increment by 2
![while loops while condition true alertTrue maybe the condition changes While loops while loops while (condition == true){ alert("True"); //maybe the condition changes } While loops](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-3.jpg)
while loops while (condition == true){ alert("True"); //maybe the condition changes } While loops repeat as long as the condition remains true.
![while loops previous statements while condition true alertTrue subsequent statements The while loops //previous statements … while (condition == true){ alert("True"); } //subsequent statements… The](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-4.jpg)
while loops //previous statements … while (condition == true){ alert("True"); } //subsequent statements… The loop would be passed over if the condition were never true--Just like an if statement.
![do while loops do alertTrue maybe the condition changes while condition do while loops do { alert("True") //maybe the condition changes } while (condition ==](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-5.jpg)
do while loops do { alert("True") //maybe the condition changes } while (condition == true); When the program reaches this point, the loop would execute at least once. The condition is at the end of the loop.
![Breaking out while condition true alertTrue if tired true break subsequent Breaking out while (condition == true){ alert("True"); if (tired == true) break; } //subsequent](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-6.jpg)
Breaking out while (condition == true){ alert("True"); if (tired == true) break; } //subsequent lines While loops repeat as long as the condition remains true…. unless we break out of the loop. For loops repeat their iterations* as scheduled until a break is reached. *Iteration: Geekspeak for times.
![continue var x 5 while x 10 x if x continue var x = 5; while (x < 10) { x++; if (x ==](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-7.jpg)
continue var x = 5; while (x < 10) { x++; if (x == 7) continue; document. write(x + "<BR>"); } Continue continues on with the next iteration of the loop.
![for in loops Similar to the previous but cycle through all properties of for … in loops Similar to the previous but cycle through all properties of](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-8.jpg)
for … in loops Similar to the previous but cycle through all properties of an object. Know they exist. They are handy, particularly for debugging. for (i in document) { document. write("<p>" + i =" "); document. write(document[i]); }
![Loops and Arrays Loops are very often used with arrays Remember arrays Loops and Arrays ® Loops are very often used with arrays. ® Remember, arrays](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-9.jpg)
Loops and Arrays ® Loops are very often used with arrays. ® Remember, arrays are objects that consist of several subscripted variables: my. Array = new Array(); my. Array[0] = 24 my. Array[1]= 12 my. Array[2] = 4
![Looping through an Array for i0 i 2 i alertmy Arrayi Looping through an Array for (i=0; i <= 2; i++) { alert(my. Array[i]) }](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-10.jpg)
Looping through an Array for (i=0; i <= 2; i++) { alert(my. Array[i]) }
![Putting it all together my Array new Array my Array0 24 my Putting it all together: my. Array = new Array(); my. Array[0] = 24 my.](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-11.jpg)
Putting it all together: my. Array = new Array(); my. Array[0] = 24 my. Array[1]= 12 my. Array[2] = 4 for (i=0; i <= 2; i++) { alert(my. Array[i]) }
![Summary of Loops for loop while loop do while loop Summary of Loops ® for loop ® while loop ® do / while loop](https://slidetodoc.com/presentation_image_h/e12917ffdb0dbc9053603a146c4751f1/image-12.jpg)
Summary of Loops ® for loop ® while loop ® do / while loop ® for / in loop for use with object properties ® break finishes the loop altogether ® continue goes directly to the next iteration ® Much can be accomplished with arrays and loops
Kevin harville
Kevin harville
Var 1721 för stormaktssverige
Söz var kəsdirər başı söz var kəsər savaşı
Oracle plan de ejecucion
Virtual loops
Loops o repeticiones
Looping bersarang
Loops in sequence diagram
Geothermal horizontal loop design
Structured text array
While loops and if-else structures
Nested loops storytelling