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

JavaScript JavaScript Foundations Functions Return Values

Joe Williams
Joe Williams
16,945 Points

This makes no sense to me. Is a parameter an argument?

I don't understand this challenge. When is says the function takes a parameter, does it mean an argument?

How do I pass in an array?

2 Answers

Michael Hulet
Michael Hulet
47,912 Points

The terms "parameter" and "argument" can be used interchangeably. I like "parameter", but it's a preference thing.

You would pass an array into a function in JavaScript like you would any other parameter. Lets say you have a function that just returns what it is passed, like this:

function echo(parameter){
    return parameter;
}

You can pass it anything you want, and it would simply return what you passed. This includes arrays. One way you can pass an array to it is like this:

var array = [1,2,3,4,5,6]; //You can make this array hold anything you want. I just put in some numbers
echo(array);

Or you can simply pass an array literal, like this:

echo([1,2,3,4,5,6]); //Again, you can make the array hold anything you want
Joe Williams
Joe Williams
16,945 Points

Thanks, that's very helpful. I have completed the challenge now.

I still don't get the question that's set for the challenge though. At no point in my correct solution did I use an array, at least intentionally, but the question made me think I had to.