Tell us what’s happening:
`` I have been following the instructions and examples but I still get an error code saying
functionWithArgs(7,9) should output [16] ```
Your code so far
// 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(1 + 2) + (7 + 9);
}
functionWithArgs(3, 16);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36.
Challenge: Passing Values to Functions with Arguments
As I can see, your call to console.log isn’t correct. You’re dealing with primitive values (1 + 2) while you should be dealing with the arguments a and b in order to get the correct result.
// Only change code below this line.
function functionWithArgs(a, b) {
console.log(1 + 2) + (7 + 9); //Double check this line
}
thanks for responding so quickly! I guess what i am asking is, why am I only able to get the correct output for the first parameter (1 + 2 = 3) but not for the second (7 + 9 = 16)? How do I refer to both arguments, not just one?
/ 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(1 + 2) + (7 + 9);
// this is what's happening here: 3 + 16 = 19
// you need to pass in the arguments! (hint)
}
functionWithArgs(3, 16);
/ Only change code below this line.
function functionWithArgs(a, b) {
console.log(a + b);
// pass 7 into a, and 9 into b!
}
console.log(functionWithArgs(7, 9)); // 16