Basic JavaScript - Passing Values to Functions with Arguments

Tell us what’s happening:

I know how to get the correct answer. However, I would like to know WHY you can’t set the function up like this-- using console.log AFTER executing the block of code, not before.

I am wondering if this is ALWAYS the case…Or, only in this example because this is how freecodecamp is asking you to set up this example.

Thanks!

Your code so far

function functionWithArgs(param1, param2){
 (param1 + param2);
}
console.log(functionWithArgs(1, 2));
console.log(functionWithArgs(7,9));

Your browser information:

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

Challenge Information:

Basic JavaScript - Passing Values to Functions with Arguments

The instructions are clear:

  1. Create a function called functionWithArgs that accepts two arguments and outputs their sum to the dev console.
  2. Call the function with two numbers as arguments.

Always follow them as it is a way ‘freecodecamp’ works.

1 Like