For this, let's take the connect4.js example. In the initialize function, Math.random() is used to decide who will have the first turn.
Instead, let's make it so we can pass the 'turncolor' in as a variable. To do this, we will add a parameter to both the connect4 and the initialize function, as well as adding the logic to handle the parameter:
This means we can still call our connect4.js example normally, but in addition, we can also call it with a parameter. Both of the following alias URL's are valid:
The names of the GET parameters in the URL are irrelevant. What is important is the sequence they are passed in and the sequence should always match the order of the calling program's parameters.
For example, let's use this program function:
Valid ways of calling this via an alias are:
An invalid way might be: