160 likes | 251 Views
In this JavaScript presentation, we learn all about loops. Loops are the basic programming construct that execute a piece of code repetitively as long as a particular condition is satisfied. <br><br>This presentation on JavaScript loops include the following topics: <br>1. What are loops?<br>2. For loop<br>3. While loop<br>4. Do-while loop<br>5. Breaking out of a loop<br>6. Skipping a loop cycle<br><br><br>This JavaScript Certification course helps you master the JavaScript programming language in an all-inclusive training program that includes complete JavaScript fundamentals, jQuery, Ajax, and more. You will apply your skills by building a real-time chat application.<br><br>JavaScript Course Overview:<br>This training program entails the fundamentals of JavaScript, including the enumeration and elaboration of various data types in JavaScript, an explanation of loops and conditional statements in JavaScript, and an overview of the concepts of objects and variables in JavaScript.<br><br>JavaScript Certification Key Features<br>1. 100% Money Back Guarantee<br>2. 7 complete JavaScript courses<br>3. Covers Ajax, jQuery, and node.js<br>4. Build a real-time chat application<br>5. Course completion certificate<br><br>ud83dudc49Learn more at: https://bit.ly/2SDfYlR
E N D
What’s in it for you? • For loop • While loop • Breaking out of a loop • Skipping a loop cycle
What is a loop? A loop is a programming construct that executes a piece of code as long as a certain condition is met Loops Exit controlled Entry controlled
For loop start Increase n by 1 for n= 0 to 9 Print “Looping” 0<n<10 n>10 end
For loop Counter variable – Keeps track of how many times the code has been executed Counter variable increment Usually +1 for(i=0; i<5; i++) Condition code – Keeps looping until the condition is met
While loop start while(condition) Execute code true false end
While loop The variable is the value that will change while (variable < endingCondition) Maximum value a variable can reach
Do - while loop start Execute code while(condition) true false end
Breaking out of loop Break is used to break out of a loop for(i=1;i<=10;i++) { document.write ( i + “is the current number) if( i==5 ){ break; } }
Skipping a loop cycle To skip a particular loop, continue is used for(i=1;i<=10;i++) { if( i==3 ){ continue; } document.write ( i + “is the current number) }