Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Jordan Lungwe-Forde
Jordan Lungwe-Forde
737 Points

Can someone explain why adding multiple parameters to functions can be useful

I'm currently learning how to add parameters to functions and I think I get it. I'm just struggling to understand why this can be beneficial.

In addition to this, how the relationship between parameters and arguments be described?

Many thanks in advance!

1 Answer

Alessandro Calorì
Alessandro Calorì
10,241 Points

Functions are a mathematical concept: you take some values in and return a value as result. In math functions are written as follows "y = f(x1, x2, ... , xn)" where "y" is the result of the computation and "x1, x2... xn" are the parameters used by the function "f" to calculate the outcome.

Functions in computer programming are the same: you give them a variable number of parameters and you get a value back. I make an example to make things clearer: suppose you want to write a function "Add" which takes in two numbers and returns the sum of the two values. A function such this is useless if it would take only one parameter.

function Add(a, b) {
  return a + b;

Most of the functions you will be working with will have multiple parameters. More advanced programming languages such as Go and C# (with the recent addition of tuples in the language syntax) allow also to return multiple values from a function (for example the result and a status message).