Basic JavaScript - Passing Values to Functions with Arguments

Tell us what’s happening:

I can’t solve this. Im highly sure that i don’t get what is said in the instructions.
can you tell me in an easy way?

Your code so far

function functionWithArgs(a){
  console.log(1 + 2);
}
function functionWithArgs(a){
  console.log(7 + 9);
}
functionWithArgs(a);
functionWithArgs(b);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0

Challenge Information:

Basic JavaScript - Passing Values to Functions with Arguments

you’ve declared the function functionWithArgs twice with the same name

Create a function called functionWithArgs that accepts two arguments and outputs their sum to the dev console.

function functionWithArgs(a, b)

then in the console.log put a+b …

1 Like

I changed the code to this. But still not working.

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

you have two functions with the same name, you need only one

2 Likes

so how do i do it? can i put two console.log inside the same function? and am i supposed to use a and b to set.
like a = 1 +2 etc.

1 Like

delete one function ,you should have only one

2 Likes

Deleted! Now it looks like this

function functionWithArgs(1,2) {
  console.log(1 + 2);
}
2 Likes

cal you function in the end

2 Likes

insted of 1 and 2 add a and b in the function and in the consol
but leve the numbers in the coling function


2 Likes

like this???


2 Likes

yes you have a single function functionWithArgs that takes two parameters (a and b ) and logs the sum of these parameters. When you call the function with specific numbers, it will output the correct sum to the console.

But this won’t work isnt it? cause i havent declared any values for a and b.
edit: no it worked!!!

1 Like

It’s good that you solved the challenge, however, the forum does not allow the direct posting of solutions. I am going to edit your reply and remove the solution.

1 Like

Thank you so much :heart:@zaklina .It worked

1 Like

Okay…I’m sorry i did’nt know that. I’m New to the Forrum

2 Likes

Happy coding… glad to help…

1 Like

No worries.
Keep up the good progress.

1 Like

Thank you so much…I have been trying to figure out this problem for almost an hour. THANK YOU…THANK YOU …THANK YOU… :heart: :heart: :heart:

2 Likes

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