We have variable x with value of "Welcome to WebArtz.". Then we have for loop. How it works? Inside brackets first we write a value of some integer, we call it always i (most common) and set value to zero. After we do that, we set condition. I said, if i is less then 10 preform this code. So we see i is zero so code will be preformed forever. To stop that we just add i++ which mean that i will increase 0-1-2-3-4-5-6-7... till it get 10 and there it stop. So, I made a condition that some peace of code will be preformed 10 times without writing that code 10 time. Preatty cool, right? There is another example:
Here, everything is same just the task will be preformed 10 times and that task is alert box. If you want that alert box preform infinitive (for trolling people) just do this:
So what i did here? Just changed form i++ to i-- . Why? Well if I say number i which is zero will decrease to -1,-2,-3,-4... that mean it will never reach number 10, and thats why this script will run forever.
|Notice : These tutorials are copyrighted by WebArtz Forum. You may not publish it on anywhere without written permission from the administrators.|