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
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.