# Passing Values to Functions with Arguments weird thing

So I was doing this lesson, and I noticed that the console prints 3, 3, then 16, then 3 again.
Why does this happen? Where does the 16 come from?
Code below

function functionWithArgs(param1, param2) {

console.log(param1 + param2);

}

functionWithArgs(2, 1);

// console output
3
3
16
3

Hi @Sitka !

It would help to see what lesson you are on.

Sorry, I thought I included that information.
I don’t remember what lesson it was…
But I included the code that produced the outcome

I found the lesson.

functionWithArgs(7,9)

If you were to test your function with that function call then that is where the 16 comes from.

I don’t understand, can you elaborate? I still don’t know where the 16 comes from.

So this function here

function functionWithArgs(param1, param2) {

console.log(param1 + param2);

}

works with any two numbers.

one of the tests cases in the challenge has this function call
functionWithArgs(7,9)

When you call that function with that function call I just pointed out then it will return 7+9 which is 16.

you say “if you call that function with that function call” then it returns 16
but I never called that function call, so where is it coming from?

Ahh I see where the problem is.

There are additional function calls going on in the background when you hit run tests.

FCC has added multiple function calls in their tests to check and see if your code is correct.

The four numbers you are seeing represent the four FCC tests.

Test 1. Did you write a function. You could have passed in any two numbers and when you hit run tests it will show up in the console.
For example, if I use this function call.
functionWithArgs(11, 11);
then the first number you see should be 22. and it is.

Test 2. functionWithArgs(1,2) should be 3. You can see in the screen shot that the second number is 3.

Test 3. functionWithArgs(7,9) should be 16. That is where the third number comes from.

Test 4. Checks to make sure you called the function. that is where the last number of 22 comes in.

Hope that makes more sense!

Why is it running a function I didn’t write?

I get it that it returns 16 because 7+9 = 16 or whatever, but that doesn’t explain why it’s running an additional function I didn’t write.

Edit:
All FCC challenges have tests running in the background.
So maybe that is where the confusion is coming from.

What is throwing you for a loop is that this is the first time you are actually see the results of the FCC tests in your console.

It is just testing your function against different numbers.

make sense?

If you are curious, here are the actual tests for the challenge.

I understand that it is confusing because this is the first time you are actually seeing the results from the FCC tests in your console.
In all of the other challenge these results were hidden from you.

But that is what those four numbers represent.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.