Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In addition to the standard functions that we've seen so far, there are more complex functions called parameter functions. So, what are parameter functions? Parameter functions are a way for functions to have more versatility. What that means is that you can provide different input for the same function. In other words, you can perform the same process with different input. In a parameter function, input is called a parameter, and it's a lot like a variable. So, what does a parameter function look like when you create it? You add a colon after the function name, the received data type is in parentheses, that's the input for the function.
The received data variable, or again, parameter name. And finally, when executed, the function uses a colon and then the value after the name of the function. So, let's look at an example in actual code of what a parameter function looks like. Think of exercising. You have the concept of exercising, and that would be the function of exercising. But every time you exercise, you don't necessarily exercise for the exact same amount of time. So if you had an app that was tracking the number of minutes that you exercised, then you could send it, whether you exercised for 30 minutes or 60 minutes.
And the exercise function could then add up your total amount of exercise based on the number that's passed in. So the top two lines are executing the exercise function, passing in values of 30 and 60, respectively. The exercise function receives that integer value as the number of minutes parameter. Within the function, number of minutes can be used like a variable that's known only to the exercise function. And again, this reduces redundancy in code, because we can use the same function and have different input.
And so, if you wanted to keep track of the amount of exercise over a period of time, you add to it in the amount that's passed in through number of minutes. And just like regular functions, parameter functions have the same rules. Start with a lowercase letter. Only use letters, numbers, and underscores. Use camelCase. And don't use any reserved words.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 105259 Viewers
56 Video lessons · 117029 Viewers
71 Video lessons · 86219 Viewers
131 Video lessons · 41220 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.