Looking for Deeper Understanding

Tell us what’s happening:
The following code passed the tests for this challenge, but I notice In the console there are some additional values being displayed. At first is prints 5, then undefined, 3, 16, 5,undefined. What’s happening here?
Thank you for any and all input!
Your code so far

function functionWithArgs(arg1,arg2) {
console.log(arg1 + arg2);
}
console.log(functionWithArgs(2,3));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15

Challenge: Passing Values to Functions with Arguments

Link to the challenge:

That’s just the tests calling your function to test it (it passes in some other numbers too, which is why you are seeing 16). Also, since you put your function call in a console.log and your function doesn’t explicitly return a value it returns undefined which is why you are seeing that as well. Take your function call out of the console.log (it’s not needed) and the undefined will disappear.

1 Like