This is really important. If you use only HTML, your page is somewhat static. You can use it to give information, or receive information to be sent to you. It serves both those purposes very well.
Check out the little adding machine I made. Punch in a couple numbers and hit the ADD Key.
Pretty simple, but what's actually occurring behind the scenes is an incredible thing. This little Number Adder works because it's driven by an actual computer program which is embedded into this webpage. It's a simple program that a chimpanzee could write with a little training, but it's a program nonetheless. The important thing is that when you input those two numbers and press the button, the work is done right there on your computer instead of being sent to mine.
A computer program is nothing more than a very detailed list of instructions. Contrary to popular belief, computers are not very smart, and when we tell them to do something, we have to explain it in detail. Because computers talk in a very strange languge consisting of 1's and 0's, and we don't, communicating these instructions in machine language would be a very complicated thing.
The answer to this dilemna is that we write our instructions in a go-between language which the computer has learned to translate into 1's and 0's. We're kinda happy, the machine's kinda happy, and the end result is that you can type a 5 and a 7 into the box above, hit a button, and learn that the sum is 12.
The important thing to remember is that your code will be placed (Nested) between an opening and closing SCRIPT tag.
You'll recognize a Function because it begins with the word "function" followed by a name and a set of parenthesis.
Immediately after the parenthesis, you'll see several lines of code enclosed in a pair of curly braces. These are the commands which the function will execute.
Notice, in the example above, I named my function "Grizz". I did that to demonstrate that I can name my project anything I want.
Now let's suppose that in real life, my household chores were defined in a function. It might look something like this:
take out trash;
sweep kitchen floor;
make needed repairs;
She might like that!
This is a simple function which executes 1 command; It changes the background color of a webpage. Notice it followed the format of:
commands in curly-braces;
|Practice this lesson's HTML in the|