1
00:00:00,090 --> 00:00:01,290
Welcome back.

2
00:00:01,950 --> 00:00:04,600
Let's improve our function a little bit.

3
00:00:04,620 --> 00:00:08,880
Talking about function parameters and function argument.

4
00:00:09,060 --> 00:00:11,720
Okay, so let me comment out.

5
00:00:11,780 --> 00:00:13,410
Maybe in the future we can reference this one.

6
00:00:13,410 --> 00:00:20,220
So let me copy this one, this function, and then come down here and then comment out this function.

7
00:00:20,250 --> 00:00:23,070
And now I have the name of the function here.

8
00:00:23,250 --> 00:00:25,290
So let's talk about function.

9
00:00:25,590 --> 00:00:27,570
I mean, function parameters.

10
00:00:27,570 --> 00:00:29,700
So these are the parameters.

11
00:00:29,730 --> 00:00:32,220
These are the values you pass into the function here.

12
00:00:32,790 --> 00:00:35,850
So what do I pass in here is what you call parameters.

13
00:00:35,850 --> 00:00:37,830
So what are the parameters doing here?

14
00:00:38,190 --> 00:00:47,510
One, this function is not reusable because any time I call the function, it's giving me 28.

15
00:00:47,520 --> 00:00:47,820
Yes.

16
00:00:47,820 --> 00:00:51,180
Adding these two numbers together to give me 28.

17
00:00:51,210 --> 00:00:54,270
Anyway, I call the function is still 28.

18
00:00:54,270 --> 00:00:57,340
So this function is not reusable.

19
00:00:57,360 --> 00:01:00,960
So how can we make this function reusable?

20
00:01:00,990 --> 00:01:05,110
That's why we need parameters and argument.

21
00:01:05,220 --> 00:01:10,890
So now, instead of just passing the values, let me remove everything from this function.

22
00:01:10,890 --> 00:01:13,810
Now to here comes this function.

23
00:01:13,830 --> 00:01:19,800
First of all, before we pass in the parameters, meaning the value passing here, you need to actually

24
00:01:19,800 --> 00:01:20,310
save.

25
00:01:20,980 --> 00:01:24,970
What kind of data you want to pass into this function?

26
00:01:25,690 --> 00:01:30,550
Well, because this function, if I call it, I won't accept two numbers.

27
00:01:30,880 --> 00:01:38,410
So we can name it whereby we can see that this can be number one or and then number two, meaning number

28
00:01:38,410 --> 00:01:40,000
one and number two.

29
00:01:40,030 --> 00:01:48,190
Or we can make it X and Y, meaning this function we take into values called x and Y.

30
00:01:48,890 --> 00:01:49,560
Perfect.

31
00:01:49,580 --> 00:01:55,520
So inside the body, then we can add these parameters.

32
00:01:55,520 --> 00:01:57,530
So this is what you call parameters.

33
00:01:57,590 --> 00:02:00,490
If there is a percentage, the function is called parameters.

34
00:02:00,500 --> 00:02:04,130
So now I can declare a variable.

35
00:02:04,160 --> 00:02:05,960
I can use var or let's.

36
00:02:05,960 --> 00:02:08,479
But like I said, let's stick to lead and cost.

37
00:02:08,900 --> 00:02:14,030
I can see that result is equal to x plus.

38
00:02:15,110 --> 00:02:17,060
Why now?

39
00:02:18,630 --> 00:02:21,930
You see, if I save this one, you see that?

40
00:02:21,930 --> 00:02:24,240
Look at the number of lines we have here.

41
00:02:24,510 --> 00:02:27,060
This one, we have almost one.

42
00:02:27,210 --> 00:02:29,850
One, we have many lines of code here.

43
00:02:29,850 --> 00:02:33,630
We have one, two, three, four, five, six.

44
00:02:33,630 --> 00:02:37,290
And this one we have one, two, three even.

45
00:02:37,290 --> 00:02:38,400
I think we have one here.

46
00:02:38,700 --> 00:02:39,270
Okay.

47
00:02:39,270 --> 00:02:46,740
So to do that, we need to console.log the result as before, we see that we are making the code a bit

48
00:02:46,740 --> 00:02:50,790
cleaner than before improving upon our our function.

49
00:02:50,790 --> 00:02:56,850
If I save this one, we see that I get an A and we have a topic.

50
00:02:56,850 --> 00:03:04,230
Talk about numbers so that we have what is called not a number because we are trying we add X and then

51
00:03:04,230 --> 00:03:08,040
y which doesn't exist for this one.

52
00:03:08,040 --> 00:03:11,190
JavaScript says that, well, these are a number, right?

53
00:03:11,430 --> 00:03:20,640
So one, first of all, we have passed in the the parameters this function receiving two numbers to

54
00:03:20,640 --> 00:03:21,270
add up.

55
00:03:21,540 --> 00:03:25,260
But when you call the function, you are not passing those values.

56
00:03:25,470 --> 00:03:26,910
So look at it here.

57
00:03:26,940 --> 00:03:32,550
So the value you pass into the function when you call it is what you call agreement.

58
00:03:32,550 --> 00:03:35,550
So here we can add any number together.

59
00:03:35,550 --> 00:03:37,470
Let's say two, comma, three.

60
00:03:38,280 --> 00:03:40,290
So here you go.

61
00:03:40,830 --> 00:03:44,880
We see that this function is a is receiving two things.

62
00:03:45,210 --> 00:03:46,890
First, X and Y.

63
00:03:47,650 --> 00:03:53,320
So it means that if you call the function into passing in those values as that.

64
00:03:53,320 --> 00:04:01,440
So here this X represents the first one and the Y represents the second one.

65
00:04:01,450 --> 00:04:03,910
So it is what you call parameters.

66
00:04:04,800 --> 00:04:08,010
And it's what you call the argument.

67
00:04:08,040 --> 00:04:13,440
So if you take that now, X has become two and one has become three.

68
00:04:13,470 --> 00:04:16,320
X is this one and why is this one?

69
00:04:16,649 --> 00:04:25,290
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.

70
00:04:25,320 --> 00:04:26,490
That is great.

71
00:04:26,490 --> 00:04:32,880
So with function parameters and function argument, this function is now usable.

72
00:04:33,180 --> 00:04:36,150
I can pass anything, any number.

73
00:04:36,150 --> 00:04:36,930
I want to add this.

74
00:04:36,930 --> 00:04:41,190
I want to add 1.4 plus

75
00:04:41,220 --> 00:04:47,010
9.63215324678.

76
00:04:47,670 --> 00:04:51,690
This function will work because now I have two things I passing this and that.

77
00:04:51,690 --> 00:04:55,650
So if I save it now the function is crazy.

78
00:04:55,680 --> 00:04:59,580
And for me it has done the hard work for me without me thinking about it.

79
00:05:00,360 --> 00:05:04,470
So now this function is really usable.

80
00:05:05,490 --> 00:05:06,270
You get it?

81
00:05:06,390 --> 00:05:07,110
That is it.

82
00:05:07,110 --> 00:05:10,730
So you would understand this concept now why not?

83
00:05:10,740 --> 00:05:13,140
We are a way to become a JavaScript developer.

84
00:05:13,710 --> 00:05:21,440
One more left to make complete function creator is what you call the return keyword.

85
00:05:21,450 --> 00:05:22,900
So let's solve that one.

86
00:05:22,920 --> 00:05:26,800
The next video or I'll show you one in the next video.

87
00:05:26,820 --> 00:05:32,400
So before we continue or in this video, let's do this particular assignment here.

88
00:05:32,700 --> 00:05:41,220
So you are of course, your assignment is that create let me make here as exercise C.

89
00:05:42,720 --> 00:05:43,150
Let's see.

90
00:05:43,170 --> 00:05:44,460
One create.

91
00:05:45,510 --> 00:05:47,100
If function.

92
00:05:48,310 --> 00:05:50,650
That will.

93
00:05:52,550 --> 00:05:54,050
Multiply.

94
00:05:55,840 --> 00:05:56,890
Three.

95
00:05:58,080 --> 00:06:00,450
Numbers and.

96
00:06:01,370 --> 00:06:02,510
Display.

97
00:06:03,370 --> 00:06:05,170
The answer.

98
00:06:06,110 --> 00:06:07,160
In the console.

99
00:06:08,510 --> 00:06:11,150
Think about this question and give a try.

100
00:06:11,180 --> 00:06:14,690
The next video, I will show you how and why I saw it.

101
00:06:14,810 --> 00:06:15,230
All right.

102
00:06:15,230 --> 00:06:15,950
Good luck.

103
00:06:15,980 --> 00:06:17,840
To solve this kind of exercise.

