Basic JavaScript - Passing Values to Functions with Arguments

Tell us what’s happening:

Describe your issue in detail here. I am able to produce the desired outcome with my code. But two of the tests are not passing.

  • functionWithArgs(1,2) should output 3.

  • functionWithArgs(7,9) should output 16.

Your code so far

function functionWithArgs(arg1, arg2) {
var result = arg1 + arg2;
console.log(“Sum:”, result);
}

// Call the function with two numbers as arguments
functionWithArgs(1, 2);
functionWithArgs(7, 9);

function functionWithArgs(arg1, arg2) {
    var result = arg1 + arg2;
    console.log("Sum:", result);
}

// Call the function with two numbers as arguments
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/120.0.0.0 Safari/537.36

Challenge Information:

Basic JavaScript - Passing Values to Functions with Arguments

Very often instructions need to be taken very literally. In here functionWithArgs(1, 2) is expected to print to console 3, not the Sum: 3.

Hello @prithasharma04 !

@sanity has provided great guidance.

Suggestion: Try calling only one log, instead of two with console.log().

I would try the ones there, but each by itself.

If this helps you, please remember to check Solution by @sanity

Happy coding! :sun_with_face:

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