Area of a circle is 3.14 * radius * radius
For this exercise, we will need to do the following:
We start with the skeleton for the code. There should be:
This should all be enclosed in the JQuery for loading the document
In the main() routine, we add some code that will call function to do the calculation and output the result
This all takes place on one line of code.
You can see that here:
The function needs to receive a value to use. We use a named placeholder for this value. In the main() routine it is passed as a number but in the function it is represented with a name. We call call this "passing a parameter"
The named placeholder is a variable when it is inside the function (i.e. it's value is not fixed until the function is passed the value).
The function uses the variable to carry out the calculation. This is just like algebra where we have letters that are then substitued for actual values when the algebra is used.
So,
You can see that here: