Basic JavaScript - Passing Values to Functions with Arguments

What am I doing wrong?
Describe your issue in detail here.

Your code so far

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

functionWithArgs();

function functionWithArgs(7, 9) {
  console.log(7 + 9) 
}

functionWithArgs();

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; PPA-LX2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Mobile Safari/537.36

Challenge: Basic JavaScript - Passing Values to Functions with Arguments

Link to the challenge:

Hi @Ashleylocs !

I would reset the lesson.

When you are creating the functionWithArgs function, you shouldn’t use actual numbers like 1,2,7, etc.

Instead you need to create what are called parameters which are placeholders for the real values for when the function is called.

Like in the example here

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

Then when you call the function, that is where you will pass in actual numbers which are called arguments.

This is also a good article on how functions work that should help you with the challenge

Hope that helps!

2 Likes

Thnak you very much Jess! You helped a lot. The article also helped :heart:

1 Like

The problem is that I used the concatenation operator (+) instead of a comma (,) when I was calling the function.

1 Like

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