The Tipster... Tip-O-Rama...
Once again we're dealing with a random number script or set of scripts (it's actually two). Here again is what the script's output looks like followed by the script itself.
And here's what it all looks like:
Notice it follows the traditional function format except that the instance, those two parentheses, now have something written in them. That's new, huh? That's saying that the author wants this function to operate on that variable alone. By stating that, the author can give that variable a value later. In the case of this script, it's a hard number written right into the code, but if you want you can set the variable to be filled in by a prompt. The prompt would pop up, ask the viewer which number should be the upper limit, and that number would be set as the "upper_limit" variable. Make sense?
Okay, so where do we get the upper limit? It comes in the second script in this line:
var upper_limit = 50;
You could have probably guessed that, though. See how it's set as a variable?
So, look at what is happening: You create a function that will manipulate numbers to get a random number somewhere between one and "something" by using a variable called "upper_limit." That's all loaded into the memory. Then the second script is enacted and the variable "upper_limit" is given a value. The function runs and a number is produced. It's actually a pretty clever and compact way of doing things.
The question now is... how do those numbers and letters get to the page? It is a mystery that will have to wait until next week.
Next Time: document.write