Let’s take another look at the definition of the function
square from the previous exercise:
n is a parameter of
square. A parameter is a variable that is an input to a function. It says, “Later, when
square is used, you’ll be able to input any value you want, but for now we’ll call that future value n.” A function can have any number of parameters.
The values of the parameters passed into a function are known as the arguments. Recall in the previous example, we called:
Here, the function
square was called with the parameter
n set to the argument
Typically, when you call a function, you should pass in the same number of arguments as there are parameters.
- When defining a function, placeholder variables are called parameters.
- When using, or calling, a function, inputs into the function are called arguments.
Check out the function in the editor,
power. It should take two arguments, a base and an exponent, and raise the first to the power of the second. It’s currently broken, however, because its parameters are missing.
___s with the parameters
exponent and then call the
power function with a
37 and an