Passing values to functions using arguements

Tell us what’s happening:
I’m unable to understand the concept of passing values to function using strings as parameters.

Your code so far


function funtionWithArgs(x,y){
console.log(x+y);
}

funtionWithArgs(1,2);

funtionWithArgs(7,9);
console.log(x+y);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36.

Challenge: Passing Values to Functions with Arguments

Link to the challenge:

Function parameters can be of any type that exists in JavaScript, including another functions

Hey @suryadoulagar,

A parameter can take anything, even a function. What it does in the background is it created a LOCAL variable that only That specific function can use. Let’s use your example:

function funtionWithArgs(x,y){
//IN the background where you can't see it, there are these 2:
//let this.x = x;
//let this.y = y;
//so with the arguments 1,2 passed that means:
//let this.x = 1;
//let this.y = 2;
//You can't see any of these, but it's happening in the background.
console.log(x+y);
}

funtionWithArgs(1,2);

More about functions here:

your issue is this, your last line of code, outside the function x and y are not defined and you get an error that may stop the tests from running