I do not know what is wrong with this code
how should I call the function
function functionWithArgs(a,b) {
console.log(a + b);
}
functionWithArgs(1+2);
functionWithArgs(7+9);
function functionWithArgs(a,b) {
console.log(a + b);
}
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/105.0.0.0 Safari/537.36 Edg/105.0.1343.50
Challenge: Basic JavaScript - Passing Values to Functions with Arguments
Link to the challenge:
hbar1st
2
This declaration here is saying that this function needs 2 values.
While down below it you are actually only giving it one value (JavaScript adds 1 to 2 and passes 3 to the function)
If you want to pass two values, don’t use plus, use a comma.
1 Like
your function has two parameters (a, b).
So, when calling it, ensure you pass in the arguments for the same syntax. in that case, I’d call:
functionWithArgs(1, 2);
functionWithArgs(7, 9);
system
Closed
4
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.