Passing values to function with argument is not working

Tell us what’s happening:

  **Your code so far**

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



  **Your browser information:**

User Agent is: Mozilla/5.0 (Linux; Android 9; SM-A305F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.105 Mobile Safari/537.36.

Challenge: Passing Values to Functions with Arguments

Link to the challenge:

Why did you define the function twice?

B/c the output have to be 3 and 16

A key thing in programming is making dynamic code, and a function is a great way to do this, and the function you’ve written is in fact dynamic so you do not need to repeat your code. Your function can take in two arguments and console.log the result of attempting to add them together, and if you want different, but expected results all you need to do is call the your function again with different arguments. You would in fact be passing the test if all you do is delete everything after your first function call.

1 Like

Ok thank you it help

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