Basic JavaScript - Passing Values to Functions with Arguments

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

const a=1;const b=2;const c=7;const d=9;
function functionWithArgs(a,b) {
  console.log(a+b);
}

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Passing Values to Functions with Arguments

Link to the challenge:

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!


What is this line doing?

You should call functionWithArgs with two numbers after you define it. This is not working in the condition of the exercise

You did not call the function anywhere. Have you tried adding a function call?

My idea is this, but this doesn’t work either

const a=1;const b=2;const c=7;const d=9;
function functionWithArgs(a,b) {
  console.log(a+b);
}
function functionWithArgs(c,d) {
  console.log(c+d);
}

Here you have declared the function twice and called it zero times.

You cannot declare a function more than once.

also… what is this line for?

Es para darle valores a los elementos de la función

You rarely want to use global variables for functions, and your functions don’t use global variables anyways. Delete that line.


Here is a function with two parameters, param1 and param2:

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

Then we can call testFun like this: testFun("Hello", "World");

You have 2 function definitions and 0 function calls. You must instead have 1 function definition and 1 function call.

These are the requirements of the exercise* functionWithArgs should be a function.

  • Failed:functionWithArgs(1,2) should output 3.

  • Failed:functionWithArgs(7,9) should output 16.

  • Failed:You should call functionWithArgs with two numbers after you define it.

I’m aware of what the requirements are. Have you read the posts where I told you what to fix?

function functionWithArgs(a,b) {
console.log(a+b);
}
With this line I solve the first three but I need the fourth one, this is what I don’t understand
sorry but my language is spanish

this is the problem :slight_smile: Failed:You should call functionWithArgs with two numbers after you define it.

That’s because you don’t have a function call:

  • Failed:You should call functionWithArgs with two numbers after you define it.

From the instructions:

So you need something that looks like myFunction(42, 99)

it does not work but thanks a lot

I can’t write the answer for you. You need to read what I wrote, think about what the question is asking, and write something that looks very similar.

mi pregunta es porque no cumplo el requisito"Failed:You should call functionWithArgs with two numbers after you define it."? function functionWithArgs(a,b) {
console.log(a+b);
}
function myFunction(42,99);

This is not a function call. You only use the keyword function when declaring a function.

Hi @dadanipe123456789 , to reinforce what @JeremyLT has been saying, you declare a function like this:

function hello (){
---function code ---
}

and call it like this:

hello();

Declare:

function hello() {
  console.log('Hello world')
}

Call:

hello();

Declare:

function myName(name) {
  let string = "My name is " + name;
  return string;
}

Call:

let intro = myName('Rambo');
console.log(intro)  // Console shows 'My name is Rambo'
1 Like

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