1 Javascript 'Do while' Statement Thu Mar 22, 2012 7:51 pm
Mr.Joker
Mr. WebArtz
Javascript 'Do while' Statement Working with 'do while' statement in javascript |
Hello again, I am Mr.Joker and today I will show you how ot use Do while loop. Its all simular but hey, there is difference. Here is code example.
Here we have a variable with value 5. I say do (because i want some code be preformed) and I want to write number + variable x. With x++ it mean variable x will be increased. Then i add while(x<20) which mean while x is less then 20 you preform this code. While here basicly say how long this code will be preformed. If i say something like:
Now variable x is 21 at start and its larger then are condition. So should it run? Yes it should, but only once. With do code we say preform this code no mather is it true or not. Better example can be seen with boolean type:
Here i said , preform this alert code as long as its false. But its false so it cant be preformed. But with do code it will be preformed only once and then stop. Thats the point of do while loop. |
Notice : These tutorials are copyrighted by WebArtz Forum. You may not publish it on anywhere without written permission from the administrators. |