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 Basics (Retired) Creating Reusable Code with Functions Review Creating Reusable Code with Functions

Mustafa Malik
PLUS
Mustafa Malik
Courses Plus Student 1,491 Points

when you call a function, you pass that function one or more____??? what is the answer

i can't get the answer right.

6 Answers

Ognjen Jevremovic
Ognjen Jevremovic
13,028 Points

Hello Mustafa, how are you? The answer I think you're looking for is "arguments" = ).

You see when you make a function, you can define as low as one (or either none, if that's the case) up to as many number of parameters as you like. So for example:

function RNG(minValue, maxValue) {
  return Math.floor( Math.random() * (maxValue - minValue + 1 ) + minValue;
}

The above example is just a simple (vanilla - pure JS code) function that returns a random number generated between the two numbers. The parameter acts just as a variable, that can only be used inside of that function scope. Meaning that minValue and maxValue "variables" (actually they are called parameters of RNG function, but as I said they just act as variables inside of that function code block).

The values that you pass in to a function, that get stored inside of the parameters defined, are called arguments (the answer to your question).

So, by calling the function defined above and by passing it two number arguments like this:

RNG(5, 25);

Will generate (and return to that same line) the random number generated between the number range (from 5 to 25 - including those aswell).

Hope that helps! All the best

Brian Holland
Brian Holland
3,508 Points

I would have to say 'argument(s)', but that seems like it should be in the video material.

Caleb Kleveter
Caleb Kleveter
Treehouse Moderator 37,862 Points

The parentheses mess up the answer, if you leave them out it should pass.

Gary Calhoun
Gary Calhoun
10,317 Points

From my understanding once you create a function, you only have to call it once for it to be registered by the interpreter as a function.

Gary Calhoun
Gary Calhoun
10,317 Points

Sorry I misunderstood the question, yes you pass arguments through a function and it can be more than one argument Brian is correct.

shang jiang
PLUS
shang jiang
Courses Plus Student 5,830 Points

When you call a function, the pieces of information being passed to that function are called:

parameter and variable is incorrect.

so the correct answer probably either string or argument.

Mustafa Malik
PLUS
Mustafa Malik
Courses Plus Student 1,491 Points

Thank you very much guys. You people have been a great help. :)