WebArtz - The Web Design Forum
Welcome to WebArtz, Guest!

WebArtz is a nice place for discussions related to web designing and coding. We help our members to code their own website templates with HTML and CSS. We give them advice on various issues.

To know more about WebArtz Forum, visit the About Us page.

At the moment, you are viewing the forum as a guest. As a guest you can't make post and participate in discussions. You need to register and become a member of the forum. Click the register link below and become a part of this forum.

Thank You

WebArtz - The Web Design Forum
Welcome to WebArtz, Guest!

WebArtz is a nice place for discussions related to web designing and coding. We help our members to code their own website templates with HTML and CSS. We give them advice on various issues.

To know more about WebArtz Forum, visit the About Us page.

At the moment, you are viewing the forum as a guest. As a guest you can't make post and participate in discussions. You need to register and become a member of the forum. Click the register link below and become a part of this forum.

Thank You


You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1Accespted 'While' loop in JavaScript Thu Mar 22, 2012 7:41 pm

Mr.Joker

Mr.Joker
Mr. WebArtz
Mr. WebArtz
'While' loop in JavaScript
Working with 'while' loop in javascript


Hello again, I am Mr.Joker and today I will teach you how to use While loop in javacript. Its really simple. Its simular to for loop but not the same. With while loop we dont have to make conditions because while is a condition allready. Here is example:

Code:
<script type="text/javascript">
x = 5;
y = 3;
while (y<x) {
document.write("Code is preformed" + "<br />");
y++;
}
</script>
Here we have two variables with integer values. First is 5 , second one is 3. And then we set while. I said, while y<x which mean, while y variable is less then x variable preform this code. And at the bottom I add y++ because it goes there , not inside brackets anymore. And how it works? Script start and see, Ok, y is 3, so its less then 5, preform it, increase y by one, y is 4 ok its still less then 5, preform code, increase y by one, y is 5, its not less then x , its equal so dont preform code. And there it stop. If you want to preform code forever just delete y++; and see what will happend. So , we can use now a boolean data type for while. Example:

Code:
<script type="text/javascript">
while (1) {
alert("I love WebArtz!");
}
</script>
With this code, script will preform forever. Why? Because whenever we type 1 inside brackets it mean we use boolean data type.
0-False
1-True
And there i said, while true(and true will always be true) preform code. If i set 0 inside brackets it will be preformed never.

Notice : These tutorials are copyrighted by WebArtz Forum. You may not publish it on anywhere without written permission from the administrators.

2Accespted Re: 'While' loop in JavaScript Tue Apr 03, 2012 12:18 pm

ankillien

ankillien
Administrator
Administrator
Tutorial Accepted

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum