Repeat Control Structure in JavaScript

Repeat Control Structure
Repetition is a structure that allows to run the same program code several times using a certain condition. Repetition in JavaScript has three forms, namely looping for, while and do-while. to make a decision. In general, branching is described as follows.

Repeat for
This loop has the following form
While loop
This loop has the following form

Do-while loop
This loop has the following form

Of the three looping forms above only for those that require initialization statements and variables. Initialization here is used as part of determining the variables that will be used to control the number of repetitions to be performed. Variables are arithmetic operations that can be done to change the value of the determinant variable. While the conditions here are used to determine when a loop block is run based on the value of the determinant variable. The workings of this loop can be described using the following flowchart
In general, for each iteration case can be applied using all three forms. For example, we can make a loop to display the "Hello javascript" message up to 3 times using the three repetitions
Experiment, make the web page as follows
Save the file with the loop name for.html.
Another example
Save the file with the loop name for2.html the results
Examples of While Repetition, Make a web page as follows
Save the file with the loop name while.html the result
Example of a Repetition of Do While, Make a web page as follows
Save the file with the loop name do while.html the results
Another example
Save the file with the loop name do while 2.html the result

0 Response to "Repeat Control Structure in JavaScript"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel