Do while loop
This function introduces the Maths object and one of its methods, namely the random() method. This generates random numbers in the range 0 - 1. The program will loop so long as the random number is greater than the limit set. In this example 0.1. Once a number less than 0.1 is generated the program is to stop. Again I have no way of telling how many numbers will be printed. If I use a while loop, then if the first number generated is less than the limit I'll never enter the loop.
In a previous example a for loop was used to generate a multiplication table. This kind of loop was used because the number of repetitions (or iterations) was known in advance. In the next example the program is going to reverse your name. The program works by starting with last character in your name, writing it down, then writing down the previous character until it reaches the first character. Since I have no way of knowing how long your name is, this would seem to rule out a for loop.
Controlling the Flow of Execution?
Fairly often, you need a script to do different things under different conditions. For example, you might write a script that checks the time every hour, and changes some parameter appropriately during the course of the day. You might write a script that can accept some sort of input, and act accordingly. Or you might write a script that repeats a specified action.