FreeCodeCamp doesn’t give you examples to copy-paste without understanding, but the explaination here is pretty good:
Parameters are variables that act as placeholders for the values that are to be input to a function when it is called. When a function is defined, it is typically defined along with one or more parameters. The actual values that are input (or “passed”) into a function when it is called are known as arguments.
Here is a function with two parameters, param1 and param2:
function testFun(param1, param2) {
console.log(param1, param2);
}
In the language presented here, the challenge is asking you to make a function with two parameters.
Then we can call testFun like this: testFun("Hello", "World");. We have passed two string arguments, "Hello" and "World".
In the language presented here, the challenge is asking you to call the function twice, each time with different arguments.
This exactly what I’ve done…I created a function called functionWithArgs and inputed two numbers into my function and we can’t only specify numbers that could be anything…
You need to fix all of the problems with your code, not just some of them.
Coding can be frustrating. You need to do exactly what the task says because the computer cannot ‘guess’ what you mean. It only understands the literal syntax you type.
You only declare the function once, but the tests call it twice.
From the instructions:
Note that you could call testFun again with different arguments and the parameters would take on the value of the new arguments.
So when the instructions say
Create a function called functionWithArgs that accepts two arguments and outputs their sum to the dev console.
That is telling you to declare the function once.
And here
Call the function with two numbers as arguments.
The instructions are telling you to call the function once. You could call it multiple times if you want.
The values passed in as function arguments are what make the function do something different on each function call. That is the purpose of the function arguments, and it is the entire reason for writing a function.
Each time you call a function, you are telling the code to execute the steps inside of the function with the specific values you passed in as arguments in place of the parameters that are part of the function definition.
You said the instruction wants me to call the function once & you also said again i could call the function multiple times…You are confusing me i must say!!!
If you have called the function twice, then you called it once as well. I’m pretty sure 1 + 1 = 2, so you need to call it one time as part of calling it twice
The tests will call your function multiple times to make sure it works correctly.