Medical Factors Which make it The most effective just by Sejal Kakadiya Medicine and health agencies with now consentrate on top quality, charge together with great satisfaction health of their solutions. These are typically that support beams which a lot of these agencies redefine the direction they trade. The following really results in thrilled clients. How come Serious Treatment Direction Can be a Trend Inside Medicine and health Sector just by Steven Orange A whole lot of North american healthcare systems' options are generally about that direction together with procedure with serious circumstances. Direction with serious health conditions which include diabetes, excessive circulation demand, cardiovascular disease, together with hypothyroidism can be a vital component of easiest treatment healthcare provider's succeed. Inside standard product, that general practitioner spots someone on an automobile accident with treatment, inspects that condition ...
Loops in JavaScript are used to execute the same block of code a specified number of times or while a specified condition is true.
In JavaScript there are two different kinds of loops which are for loop, which loops through a block of code a specified number of times and while loop, which loops through a block of code while a specified condition is true.
The for loop is used when you know in advance how many times the script should run.
{
code to be executed
}
<head>
</head>
<body>
<script type="text/javascript">
var i=0
for (i=0;i<=10;i++){
In JavaScript there are two different kinds of loops which are for loop, which loops through a block of code a specified number of times and while loop, which loops through a block of code while a specified condition is true.
JavaScript For Loop
The for loop is used when you know in advance how many times the script should run.
Syntax:
for(var=startvalue; var<=endvalue;var=var+increment){
code to be executed
}
Example:
<html><head>
</head>
<body>
<script type="text/javascript">
var i=0
for (i=0;i<=10;i++){
document.write("The number is" +i)
document.write("<br/>")}
</script>
</body>
</html>
The above example defines a loop that starts with i=0. The loop will continue to run as long as i is less than, or equal to 10. i will increase by 1 each time the loop runs.
The while loop is ued when you want the loop to execute and continue executing while the specified condition is true.
{
code to be executed
}
<head></head>
<body>
<script type="text/javascript">
var i=0
while(i<=10)
{
document.write("The number is "+i)
document.write("<br/>")
i=i+1
}
</script>
</body>
</html>
The example above defines a loop that starts with i=0. The loop will continue to run as long as i is less than, or equal to 10. i will increase by 1 each time the loop runs.
The do .... while loop is a variant of the while loop. This loop will always execute a block of code Once, and then it will repeat the loop as long as the specified condition is true. The lop alway be executed at least once, even if the condition is false, because the code is executed before the condition is tested.
{
code to be executed
}
while (var<=endvalue)
<head></head>
<body>
<script type="text/Javascript">
var i=0
do
{
document.write("The number is "+i)
document.write("<br/>")
i=i+i
}
while (i<0)
</script>
</body>
</html>
There are two special statements that can be used inside loops: break and continue.
<head></head>
<body>
<script type="text/javascript">
var i=0
for(i=0;i<=10;i++)
{
if (i==3) {break}
document.write("The number is " +i)
document.write("<br/>")
}
</script>
</body>
</html>
<head></head>
<body>
<script type="text/javascript">
var i=0
for(i=0;i<=10;i++)
{
if (i==3) {continue}
document.write("The number is " +i)
document.write("<br/>")
}
</script>
</body>
</html>
Related Posts:
document.write("<br/>")}
</script>
</body>
</html>
The above example defines a loop that starts with i=0. The loop will continue to run as long as i is less than, or equal to 10. i will increase by 1 each time the loop runs.
Preview:
JavaScript While Loop
The while loop is ued when you want the loop to execute and continue executing while the specified condition is true.
Syntax:
while (var<=endvalue){
code to be executed
}
Example:
<html><head></head>
<body>
<script type="text/javascript">
var i=0
while(i<=10)
{
document.write("The number is "+i)
document.write("<br/>")
i=i+1
}
</script>
</body>
</html>
The example above defines a loop that starts with i=0. The loop will continue to run as long as i is less than, or equal to 10. i will increase by 1 each time the loop runs.
Preview:
JavaScript do .... while Loop:
The do .... while loop is a variant of the while loop. This loop will always execute a block of code Once, and then it will repeat the loop as long as the specified condition is true. The lop alway be executed at least once, even if the condition is false, because the code is executed before the condition is tested.
Syntax:
do{
code to be executed
}
while (var<=endvalue)
Example:
<html><head></head>
<body>
<script type="text/Javascript">
var i=0
do
{
document.write("The number is "+i)
document.write("<br/>")
i=i+i
}
while (i<0)
</script>
</body>
</html>
Preview:
JavaScrpt Break and Continue Statements
There are two special statements that can be used inside loops: break and continue.
Break
The break command will break the loop and continue executing the code that follows after the loop.Example:
<html><head></head>
<body>
<script type="text/javascript">
var i=0
for(i=0;i<=10;i++)
{
if (i==3) {break}
document.write("The number is " +i)
document.write("<br/>")
}
</script>
</body>
</html>
Preview:
Continue
The continue command will break the current loop and continue with the next value.Example:
<html><head></head>
<body>
<script type="text/javascript">
var i=0
for(i=0;i<=10;i++)
{
if (i==3) {continue}
document.write("The number is " +i)
document.write("<br/>")
}
</script>
</body>
</html>
Preview:
Read Next:How to Loop Through JavaScript Array?
Related Search Terms
Related Posts:
How to Show Pop Up Boxes Using JavaScript?
How to Write Conditional Statements in JavaScript?
How to Write JavaScript With HTML?
How To Create Simple Image Slideshow Using JavaScript ?
Image Slideshow with Navigation Buttons Using JavaScript
How to create Changeable Date and Time Using JavaScript?
How to Create JavaScript Image Slideshow with LInks
How to Display Date Format in JavaScript?
How to Validate a HTML Form Using JavaScript?
What are the Different Ways to Redirect Page in JavaScript?
How to Detect Visitor's Browser Using JavaScript?
How to make rounded corners border using CSS
How to Create Custom CSS Template for Printing
How to create a simple form using HTML?
Comments
Post a Comment