After learning Javascript turned out almost the same structure with the Pascal language. Although PHP and other languages are also basically the same. Just in terms of writing, JavaScript is more similar to Pascal. So for my friends who never learned Pascal then willing to learn JavaScript, do not worry because the basics almost similar to Pascal.
Well, this time to discuss his writings about looping. Interesting because if the Pascal while loop is just one, if the JavaScript loop with this while there are two, the first while loop. the second do while loop. In terms of syntax not much different, let's take a look to the syntax below.
While: The output is a number in sequence 0-10 down.
Well, this time to discuss his writings about looping. Interesting because if the Pascal while loop is just one, if the JavaScript loop with this while there are two, the first while loop. the second do while loop. In terms of syntax not much different, let's take a look to the syntax below.
While: The output is a number in sequence 0-10 down.
<html>
<body>
<script type="text/javascript">
var i = 0
while (i <= 10)
{
document.write ("The numbers are" + i)
document.write ("<br />")
i = i +1
}
</ script>
</ body>
</ html>
Do While
<html>
<body>
<script type="text/javascript">
var i = 0
do
{
document.write ("The numbers are" + i)
document.write ("<br />")
i = i +1
}
while (i <0)
</ script>
</ body>
</ html>
In the syntax above, while it was quite hard in terms of result. While only the alias will generate an output code executed when the condition is TRUE. While the do while loop will execute the code even if only ONCE. although the condition is FALSE because the condition is executed first prior to being tested with the "requirement code" it was.
0 comments on Learning Javascript: While and Do While :
Post a Comment and Don't Spam!
Dont Spam please