Worked Example



Function to keep generating random numbers between 1 and 20 until the random number is below 4

The Program as JS Code

Here is how the code for the program is written in JS.

The concept is still that there is a controlling MAIN routine which calls a SUBROUTINE

image of function


Running the Function

Here is how the code for MAIN routine and SUBROUTINE are written in JS.

The concept is that there is a controlling MAIN routine which calls a SUBROUTINE

This video shows the order in which the program is executed.