freeCodeCamp Challenge Guide: Passing Values to Functions with Arguments

freeCodeCamp Challenge Guide: Passing Values to Functions with Arguments
0

#1

Parameters are variables that act as placeholders for the values that are to be input to a function when it is called. When a function is defined, it is typically defined along with one or more parameters. The actual values that are input (or “passed”) into a function when it is called are known as arguments.

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

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

Then we can call functionWithArgs:

functionWithArgs("Hello", "World");

We have passed two arguments, "Hello" and "World". Inside the function, param1 will equal “Hello” and param2 will equal “World”. Note that you could call functionWithArgs again with different arguments and the parameters would take on the value of the new arguments.

The answer is:

// Example
function ourFunctionWithArgs(a, b) {
console.log(a - b);
}
ourFunctionWithArgs(10, 5); // Outputs 5

// Only change code below this line.

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

functionWithArgs(“Hello”,“World”);


#2

I have same code as you but I get this as failure messages:

functionWithArgs(1,2) should output 3
functionWithArgs(7,9) should output 16


#3

In the end it was missing a ‘+’ sign in the console.log instead of a ,

// Only change code below this line.
function functionWithArgs(param1, param2) {
console.log(param1 + param2);
}
functionWithArgs(“Hello”, " World");


#4

guys can anyone tell me that where’s the problem in this.
// Example
function ourFunctionWithArgs(a, b) {
console.log(a - b);
}
ourFunctionWithArgs(10, 5); // Outputs 5

// Only change code below this line.
function FunctionWithArgs(a, b) {
console.log(a + b);
}
FunctionWithArgs(50, 13);


#5

function functionWithArgs(a,b) {
console.log(a+b);
}
functionWithArgs(1,2); \= 3
functionWithArgs(7,9); \= 16
DONE