# Functions' Parameters

Functions' parameters afford us the opportunity to pass values to functions for execution when calling such functions. Since functions can be invoked to do what they were defined for just anytime, most of the time, we won't be needing it to use same values in doing what it does. For example, if we create a function to add two numbers, it will continue to give the same result anytime it is called. This is where parameters come in. With parameters, we can then have an opportunity to pass different values to the function to add anytime we want to use it. So, parameters are variables declared in a function parentheses which can be used inside the function. We assign values to these parameters(variables) when calling the function.
``````//DEFINING A FUNCTION WITH PARAMETERS
function addNum(num1, num2){ //num1 and num2 are parameters
}

//CALLING THE FUNCTION WITH VALUES FOR THE PARAMETERS
``````<script>
}

</script>``````
From the above, you can conclude that having parameters in a function is more like creating a function that will not only do what it was created for but does it just the way you want.
``````<script>
//DEFINING FUNCTION
function stack(level){
}

//CALLING FUNCTION
stack("beginner");
stack("developer");

</script>``````
A function can have as much parameters as you want. Default Values You can assign default values to parameters especially those, the function depends on for proper execution. This will ensure when no argument is assign to a parameter during invocation, it uses its default value instead of being undefined and producing unexpected results.
``````<script>
x = (x === undefined? 0 : x);
y = (y === undefined? 0 : y);

}

</script>``````
This is same as,
``````<script>
if (x === undefined){
x = 0;
}
if (y === undefined){
y = 0;
}

}

</script>``````
In the above, we assigned 0 to a parameter if it is undefined or no argument was assigned to it. SUMMARY
1. The parameters of a function are the variables declared in the parentheses (()) of a function whose values can be assign when calling the function.
2. Parameter(s) enables us to get different results from a function whenever we invoke it and assign different values to the parameter(s).
3. A function can have as much parameters as you want.
4. You may decide to assign default values to a parameter especially important ones so that when no argument is assign to them, the function uses the default values.
Take a short quiz on Functions' Parameters.
Ask a question or tell us if Functions' Parameters is easy or not.
cent?