While Loops
The first 3 lines are a function that uses a random number generator. randomNumber() gives a value between 0 and 1, but never including 1 (between 0 and .99999). The floor makes it round down and the + 1 ensure that you never get a 0 back. the upper is the top number that the function will return.
The loop starts by declairing the variable counter and setting it to 0. Line 6 starts the loop with while and a test condition in parentheses which will run untill it tests false. In this case it is checking the counter var to see if it is less than 10. 0 < 10 so the loop will continue. line 7 creates a new variable named rand and sets the function equal to it. the 9 is the upper limit. line 8 does the purpose of the loop, in this case it writes the random number generated to the document. Finally line 9 adds the the counter variable and starts the loop over again. At this point the loop tests the condition again ( now 1 < 10 ) and continues again until the test condition is false (on the 10th pass 10 !< 10) so the loop is finished.
If this loops test condition is false, it will never run at all, and if it always tests right it is a infinite loop.