Basic JavaScript - Passing Values to Functions with Arguments - c49z7uqSwAiXrPuLhIIeT

Tell us what’s happening:
Describe your issue in detail here.
Im trying to understand how this is wrong when im doing it the way it was explained. Even after viewing the video i can see i did it the same way and im still wrong. Please help if anyone can?

  **Your code so far**
function functionWithArgs(1, 2) {
console.log(7 + 9);

functionWithArgs(3, 16);
  **Your browser information:**

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

Challenge: Basic JavaScript - Passing Values to Functions with Arguments

Link to the challenge:

You want to create a function that can accept any two numbers. So you don’t want to hard code actual numbers into the parameter list. Read the description again:

“Parameters are variables that act as placeholders for the values that are to be input to a function when it is called.”

So you want variables in the parameter list. You get to decide what to name those variables. And then you will use those variables in the function body.

so instead of using the actual numbers, use the variables instead (like created names or etc.). I feel like im wrong in what i’m asking due to being confused.

Exactly. Look at the example in the instructions:

function testFun(param1, param2) {
  console.log(param1, param2);

param1 and param2 are just variable names. They could be named anything. You get to decide what you want your parameter names to be. Usually you give them a name that describes the type of input you are expecting.

ok after reading the lesson again I am beginning to understand the variable names part. So with each function that has the set output should have variable names for the numbers and it will be recognized in the end?

Whenever you want to pass something into a function you have to give it a name in the parameter list. It doesn’t matter whether you are passing in a number, string, array, or even another function. If you want to pass something into the function so you can use it in the function body then you give it a name in the parameter list so you can access it by that name.

Ok, I’m beginning to understand this process that was confusing me. From seeing my mistakes missed a step in the process. Thank you for your help.

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