Passing Values to Functions with arguments question

Tell us what’s happening:
Describe your issue in detail here.

Why does the output show 2, 3, 16, 2? Isnt it supposed to be just 2?

  **Your code so far**

function functionWithArgs(param1, param2) {
console.log(param1 + param2);
functionWithArgs(1, 1);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36

Challenge: Passing Values to Functions with Arguments

Link to the challenge:

Those numbers you are seeing in the console are the results of the tests that are run against your code. Since your code does a console.log then each test will call your function and also do a console.log.

Hmm, not sure I understand. I don’t have any code written that would result in the output to be 3 or 16… unless I don’t understand how this works at all

the code in the editor is executed by the tests, look at the tests, see that there are different function calls with different arguments. The different numbers come from the function being called by the tests.

You aren’t hardcoding the arguments, but FreeCodeCamp is. When you write an answer(in this case your function solution), it gets tested with several arguments that
are passed behind the scene by FCC to verify your solution. Hope it helped.

1 Like