Welcome back.
Let's improve our function a little bit.
Talking about function parameters and function argument.
Okay, so let me comment out.
Maybe in the future we can reference this one.
So let me copy this one, this function, and then come down here and then comment out this function.
And now I have the name of the function here.
So let's talk about function.
I mean, function parameters.
So these are the parameters.
These are the values you pass into the function here.
So what do I pass in here is what you call parameters.
So what are the parameters doing here?
One, this function is not reusable because any time I call the function, it's giving me 28.
Yes.
Adding these two numbers together to give me 28.
Anyway, I call the function is still 28.
So this function is not reusable.
So how can we make this function reusable?
That's why we need parameters and argument.
So now, instead of just passing the values, let me remove everything from this function.
Now to here comes this function.
First of all, before we pass in the parameters, meaning the value passing here, you need to actually
save.
What kind of data you want to pass into this function?
Well, because this function, if I call it, I won't accept two numbers.
So we can name it whereby we can see that this can be number one or and then number two, meaning number
one and number two.
Or we can make it X and Y, meaning this function we take into values called x and Y.
Perfect.
So inside the body, then we can add these parameters.
So this is what you call parameters.
If there is a percentage, the function is called parameters.
So now I can declare a variable.
I can use var or let's.
But like I said, let's stick to lead and cost.
I can see that result is equal to x plus.
Why now?
You see, if I save this one, you see that?
Look at the number of lines we have here.
This one, we have almost one.
One, we have many lines of code here.
We have one, two, three, four, five, six.
And this one we have one, two, three even.
I think we have one here.
Okay.
So to do that, we need to console.log the result as before, we see that we are making the code a bit
cleaner than before improving upon our our function.
If I save this one, we see that I get an A and we have a topic.
Talk about numbers so that we have what is called not a number because we are trying we add X and then
y which doesn't exist for this one.
JavaScript says that, well, these are a number, right?
So one, first of all, we have passed in the the parameters this function receiving two numbers to
add up.
But when you call the function, you are not passing those values.
So look at it here.
So the value you pass into the function when you call it is what you call agreement.
So here we can add any number together.
Let's say two, comma, three.
So here you go.
We see that this function is a is receiving two things.
First, X and Y.
So it means that if you call the function into passing in those values as that.
So here this X represents the first one and the Y represents the second one.
So it is what you call parameters.
And it's what you call the argument.
So if you take that now, X has become two and one has become three.
X is this one and why is this one?
So if I save the function and let's see, it's going to run for us if I save it now I have five.
That is great.
So with function parameters and function argument, this function is now usable.
I can pass anything, any number.
I want to add this.
I want to add 1.4 plus
9.63215324678.
This function will work because now I have two things I passing this and that.
So if I save it now the function is crazy.
And for me it has done the hard work for me without me thinking about it.
So now this function is really usable.
You get it?
That is it.
So you would understand this concept now why not?
We are a way to become a JavaScript developer.
One more left to make complete function creator is what you call the return keyword.
So let's solve that one.
The next video or I'll show you one in the next video.
So before we continue or in this video, let's do this particular assignment here.
So you are of course, your assignment is that create let me make here as exercise C.
Let's see.
One create.
If function.
That will.
Multiply.
Three.
Numbers and.
Display.
The answer.
In the console.
Think about this question and give a try.
The next video, I will show you how and why I saw it.
All right.
Good luck.
To solve this kind of exercise.