Basic JavaScript - Passing Values to Functions with Arguments

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

the output of this code is repeating the desired output as 3 16 3 16, i’m passing the test besides number 3, the one that shoub output 3,it could be that my syntax is wrong.
Your code so far

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

Your browser information:

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

Challenge: Basic JavaScript - Passing Values to Functions with Arguments

Link to the challenge:

You should be using the function parameters (a and b) within your function. These arguments are variables. So, when the function is called, real values will be supplied to those parameters e.g. functionWithArgs(7, 9) and the function will act on them accordingly, wherever a and b are present inside the function.

As an example, let’s multiply two numbers:

function multiplyTwoNumbers(num1, num2) {
return num1*num2;
}

Now if I call this function with two randomly chosen values:

console.log(multiplyTwoNumbers(5, 21)) // returns 105

In this challenge, instead of a return statement you use console.log inside the function to display the result of adding together the two numbers supplied as arguments.

The point is that you can call your function parameters anything you like. The function will look for those parameters inside the function and act on them accordingly. Then whatever values are supplied to the function when it is called, those values will replace the parameters inside the function.

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