www.pickatutorial.com Computer Tutorials
Top eBooks: C/C++ | C# | Android | Mathematics | Database | Cloud | Graphics | Networking | Oracle | Hardware | AI
Top Tutorials: C/C++ | C#.NET | PHP MySQL | Java | Java Script | jQuery | HTML | xHTML | HTML5 | VB Script| CSS
Lessons JavaScript do...while Loop Bookmark and Share
Tutorial Home
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9
Lesson 10
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
Lesson 23
Lesson 24
Lesson 25
Lesson 26
Lesson 27
Lesson 28
Lesson 29
Lesson 30
Lesson 31
Lesson 32
Lesson 33
Lesson 34
Lesson 35
Lesson 36
Lesson 37
Lesson 38
Lesson 39
Lesson 40
Lesson 41
Lesson 42
Lesson 43
Lesson 44
Lesson 45
Lesson 46
Lesson 47
Lesson 48
Lesson 49
In the previous lessons we have learnd to use the for loop and the while loop. In this lesson we are going to introduce yet another looping construct of JavaScript i.e do...while loop.

The do...while loop is a variant of the while loop. There is just one important difference between the while loop and the do...while loop. No matter what, the do...while loop executes at least once as it chechs the loop condition after it has completed an iteration of the loop. On the other hand in the case of a while loop the condition is always checked before the exection / iteration of the loop. Its syntax follows:

do
{
//code to be executed
}
while (condition);


Example code follows:

<html>
<body>
<script type="text/JavaScript">
var i=0;
do
{
document.write("The number is " + i);
document.write("<br />");
i++;
}
while ( i < 6 )
</script>
</body>
</html>


Next >>> Lesson No. 14: break and continue





Home - Advertise - Contact - Disclaimer - About Us
© Since 2006 pickatutorial.com -- All Rights Reserved.