do{
- iValue = Math.random() * 10 // random number between 0-10
iValue = Math.floor(iValue) // round to nearest integer
Awesome!!
It is assuring to know that the algorithm will not only generate a random number between 0 and 4, but it will also take a random number of steps to finish. That's what I call taking random number generation to the next level.
The book is "Learning JavaScript" (O'Reilly) and the algorithm is shown on page 91.