Hi can someone help me on this exercise? It says have completed 3 of the 4 parts of the assignment but in actuality I think I have only completed 2 of the 4. Please help.
First make a function named functionWithArgs
which i’ve done.
Second functionWithArgs(1,2) should output 3
Which i’ve done.
Third functionWithArgs(7,9) should output 16.
the report is giving me a check mark for this one with the code I’ve written below but I don’t see how that’s right.
Fourth call functionWIthArgs. with two numbers after you define it.
How do I do this part?
Your code so far
function functionWithArgs(one, two) {
console.log(one + two);
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36.
Challenge: Passing Values to Functions with Arguments
I think what may be confusing you is the way you named the function parameters.
function functionWithArgs(one, two)
The one and two don’t just represent the numbers 1 and 2, they represent any numbers you pass into the function. So you should name them more generically:
function functionWithArgs(num1, num2)
and then in the body of the function you would do
console.log(num1+ num2);
Now do you see how any two numbers you pass into the function will print the sum of those two number?
Hi thank you so much for your response! Yes I think I understand what you are saying if I may explain it in my own words could you tell me if I’m correct or incorrect in my explanation?
The function parameters “num1” and “num2” in this exercise both represent the numerical values “1”, “2” and “7”, “9” respectively. Which is why the results show that: