Codecademy Forums

How to use an array as a parameter in a function's Declaration?

Hi. I’m trying to write a function to get an array to sort the data in it; but, I don’t know how to define an array as a parameter in the declaration. Can someone help me?

Hello, @sina1377. Welcome to the forum! Based on how you worded your question, I’m guessing you are referring to a language like C++, C# or Java. This may work depending on language:

double sumArray(int numbersToAdd[]) { //the [] specifies an array as the parameter
  //code here
  return total;
}

Hope this helps!

1 Like