Last time, we learned how to create and call functions. But our functions were pretty basic - they always did exactly the same thing every time we called them.
Engagement Message
What if we could make functions more flexible and useful?
We can! Functions can receive information from us when we call them. This information is called parameters (when defining the function) or arguments (when calling the function).
Engagement Message
Think of it like giving instructions to that helpful assistant - what information would they need?
Parameters go inside the parentheses when we define a function. Here's how we add a parameter called name
to our greeting function:
Engagement Message
Notice the variable name
inside the parentheses?
Now when we call this function, we pass an argument inside the parentheses. The argument becomes the value of the parameter inside the function:
Engagement Message
See how the same function produces different outputs?
Functions can have multiple parameters too! We separate them with commas. Here's a function that takes a name and an age:
Engagement Message
How many arguments do you think we need when calling this function?
