Basic JavaScript - Passing Values to Functions with Arguments

It is declared once, but declared incorrectly.

You cannot put strings as parameters. Parameters are variables.

You had variables as parameters here:

Then can you explain this below since i can’t have string as parameters…

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

param1 and param2 aren’t strings. Do you see how yours have quotation marks " and those don’t?

Because in the example above I can see both strings & parameters together in the code!!!

There are strings in the function call, not in the function definition. Strings have quotation marks " around them.

I changed that now to a string & I’m still not passing the challenge that says " functionWithArgs(1,2) should output 3 ."

function functionWithArgs("Code", "Hechter") {
  console.log(1 + 2);
}
functionWithArgs(1, 2);

These are still strings. You must not use strings.

You are still not using the parameters here.

I suppose the code above is meant to give me the output of 3

I guess i should use parameters if not string or what…
Can’t you just tell me exactly what I’m doing wrong because i keep changing everything & still not passing the challenge

I am telling you exactly what you are doing wrong.

This is a string:

This is also a string.

You cannot use strings in the parameter list. You did it correctly here:

Also, you are not using the parameters here:

You must use the parameters instead of specific numbers.

Okay I got that now let me work on it…

Here’s my code below again…

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

It seems to work? At least on my end.

It did here too but even though it’s kinda frustrating and Fcc confused me with the testfun(“Hello”, “World”) which is a string!!!But thank you so much I appreciate every bit of you & you should know i get angry easily each time I’m trying to solve a challenge & I don’t get it but don’t take it personal, you’re one for the future…

Bruh you hardcode you functions parameters we use variable to store the values in javascript you can define variable by using let keyword ex. let storeXValue = 20; like that
In your functions you need to define parameters in the form of variable so whenever we pass value in function these variables store the values and we can perform operations by accessing variable
See you can like this->

Mod Edit: SOLUTION REMOVED

like this

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

1 Like

ohh got it totally agree with you :two_hearts:

They expect you to figure it out yourself when you are a beginner.

This simply is not true. Help is good. We offer help. Giving answers to copy is not help.