Basic JavaScript - Passing Values to Functions with Arguments

Tell us what’s happening:

i have made the output that has everything the task wanted us to print, for some reason it just still has an error… i really need help

Your code so far

function functionWithArgs(one, two) {
  return one + two;
}

console.log(functionWithArgs(1, 2)); 
console.log(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/131.0.0.0 Safari/537.36 Edg/131.0.0.0

Challenge Information:

Basic JavaScript - Passing Values to Functions with Arguments

It’s one of these rare occasions when function is expected to log something to console, instead of returning the value…

The error you get is
functionWithArgs(1,2) should output 3
So somewhere in the code It is not outputting the correct number. Most likely the first Console log.

It seems like there is a bug, as the first console.log(functionWithArgs(1, 2));
does output 3 into the console.

As already said, the console.log must be inside the function.

  1. Create a function called functionWithArgs that accepts two arguments and outputs their sum to the dev console.

That means the function is responsible for logging “to the dev console”. As such, the log belongs inside the function.

@LingWanTing

So instead of logging in the console outside of the function, Put the log inside, and remove the Return.

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.