How to call function with two numbers as arguments?

Tell us what’s happening:

Your code so far

function functionWithArgs(2, 3) {
console.log(2 + 3);
functionWithArgs(2, 3)

Your browser information:

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

Challenge: Passing Values to Functions with Arguments

Link to the challenge:

No, when constructing a function you could pass parameters - this case, two is required- which would serve as placeholders when the function is now being called with real values.

1 Like

The words parameter and argument are often used
interchangeably, but they are distinctively different.
When passing values to a classic JavaScript function
parameters are a convenience but not a necessity.
A classic JavaScript function,function(){return “I am Function”},
has an automatically created arguments object.
Values can be passed to a function with out any parameters.

function noParams(){return arguments[0]+arguments[1]}
alert(noParams(1,2))// alerts 3

In conclusion, parameters are Not passed to
JavaScript functions, values and references
are passed and received by the arguments
object and by parameters if they are included.

1 Like

Ok, we’re entering confusing waters here! If I ask you “A equals 1. What’s A and what’s 1?” The correct answer would be “Depends”:

 * From variable’s point of view
 * A - variable name
 * 1 - it’s value
const a = 1;

 * From objects’s point of view
 * A - key or property
 * 1 - value
const obj = { a: 1 };

 * From functions’s point of view
 * A - parameter
 * 1 - argument
const fn = (a) => a + 1;

@divya_saini, I hope this will also answer your question.

1 Like

Thanks for the help. I got it.