Passings Values to Functions and calling Functions

Hi can someone help me on this exercise? It says have completed 3 of the 4 parts of the assignment but in actuality I think I have only completed 2 of the 4. Please help.

First make a function named functionWithArgs
which i’ve done.

Second functionWithArgs(1,2) should output 3
Which i’ve done.

Third functionWithArgs(7,9) should output 16.
the report is giving me a check mark for this one with the code I’ve written below but I don’t see how that’s right.

Fourth call functionWIthArgs. with two numbers after you define it.
How do I do this part?

Your code so far

function functionWithArgs(one, two) {
console.log(one + two);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36.

Challenge: Passing Values to Functions with Arguments

Link to the challenge:

I think what may be confusing you is the way you named the function parameters.

function functionWithArgs(one, two)

The one and two don’t just represent the numbers 1 and 2, they represent any numbers you pass into the function. So you should name them more generically:

function functionWithArgs(num1, num2)

and then in the body of the function you would do

console.log(num1+ num2);

Now do you see how any two numbers you pass into the function will print the sum of those two number?


I think you are mixing up how functions work a little bit. Don’t worry, that’s super common!

When you define a function

function functionWithArgs(one, two) {
console.log(one + two);

You can then call this function with any inputs and the function will execute the code you put into the function body.

For example,

functionWithArgs(1, 2)

will log 3 to the console. (Try it and see!)


functionWithArgs(7, 9)

will log 16 to the console. It doesn’t matter what you called your variables. What matters is the values that you call the function with.

1 Like

Thank you so much for your help! I see how to call up the function now. I had to put it outside of my brackets!

Hi thank you so much for your response! Yes I think I understand what you are saying if I may explain it in my own words could you tell me if I’m correct or incorrect in my explanation?

The function parameters “num1” and “num2” in this exercise both represent the numerical values “1”, “2” and “7”, “9” respectively. Which is why the results show that:

functionWithArgs(1 , 2) outputs 3


functionWithArgs( 7, 9) outputs 16

Is that right?

1 Like

Correct, num1 and num2 take on whatever values you pass into the function.

Awesome! If I may ask a follow up:

at what point did I actually pass the values of “1”, “2”, “7”&“9” into the function of this exercise?

The test suite does that part for you.

1 Like