1
00:00:00,150 --> 00:00:04,040
Welcome back to the continuation of creating a function.

2
00:00:04,050 --> 00:00:08,910
So in this video let's have a look at why do we need a function.

3
00:00:09,180 --> 00:00:15,930
So for what we have done as we talk about why we need a function, if this function is performing,

4
00:00:15,930 --> 00:00:19,740
why if any function then you would take us correct?

5
00:00:19,740 --> 00:00:21,240
Otherwise we say no.

6
00:00:21,270 --> 00:00:22,150
Have a look.

7
00:00:22,170 --> 00:00:24,030
Well, the PDF, the slides.

8
00:00:24,030 --> 00:00:25,250
Everything will be provided for us.

9
00:00:25,260 --> 00:00:25,920
So don't worry.

10
00:00:25,920 --> 00:00:28,170
Just understand what you are doing.

11
00:00:28,170 --> 00:00:28,740
Okay.

12
00:00:28,740 --> 00:00:37,350
So one functions helps to make your code more readable so that this function makes a code readable.

13
00:00:37,380 --> 00:00:45,030
Yes, because sometimes if you refer to X and Y, what does it mean as you mean this function?

14
00:00:45,030 --> 00:00:50,160
We don't have the function here like before we declare verbal like A and b x is code.

15
00:00:50,160 --> 00:00:51,810
This you don't know what x is.

16
00:00:51,840 --> 00:00:54,870
X can be let's say somebodies name.

17
00:00:54,870 --> 00:00:58,890
It can be a theory, it can be somebody's nickname, it can be whatever.

18
00:00:59,010 --> 00:01:02,580
But with function it makes our code more readable.

19
00:01:02,580 --> 00:01:09,360
Meaning that for this function, if look at a name, it tells you that we are adding something together.

20
00:01:09,360 --> 00:01:14,370
So if inside this one it tells you that well, we are adding X means number one.

21
00:01:14,370 --> 00:01:16,470
And number two, that is first point.

22
00:01:16,470 --> 00:01:17,970
So this function is correct.

23
00:01:18,270 --> 00:01:25,320
You meet the first requirement and a requirement is that functions can make your code more usable.

24
00:01:26,330 --> 00:01:30,330
Well, when we say more reasonable, what does it mean?

25
00:01:30,350 --> 00:01:37,280
Meaning that I can reference any way I want my message to be appeared.

26
00:01:37,640 --> 00:01:40,250
I will make our core dysfunction anyway.

27
00:01:40,250 --> 00:01:42,590
My code and I have access to it.

28
00:01:42,890 --> 00:01:45,080
So does this one solve it?

29
00:01:45,110 --> 00:01:52,310
I can say that it's solved only let's say three over ten for now because we haven't finished the function

30
00:01:52,310 --> 00:01:52,460
yet.

31
00:01:52,460 --> 00:01:55,150
That's why we talk about parameters and argument.

32
00:01:55,160 --> 00:01:59,810
After you going through that, then you're going to get ten over ten for this function that you created.

33
00:02:00,080 --> 00:02:03,260
So function mean is to be what, reusable?

34
00:02:03,470 --> 00:02:04,490
That's a good point.

35
00:02:04,550 --> 00:02:09,350
Next point is that function can help make your code maintainable again.

36
00:02:09,350 --> 00:02:16,040
Once it maintainable simply means that if you run out that we are writing this code, you you understand

37
00:02:16,040 --> 00:02:17,390
what is doing over here.

38
00:02:17,480 --> 00:02:25,100
But let's say that after ten years or 20 years and you take the same code because, oh, my gosh, what

39
00:02:25,130 --> 00:02:27,500
was the meaning of this one was even of X.

40
00:02:27,500 --> 00:02:32,380
But as soon as we see the name or the function is that, oh, this function is doing this.

41
00:02:32,390 --> 00:02:35,480
So maintaining that function is really easy.

42
00:02:35,480 --> 00:02:38,990
So this function also meets that perfect.

43
00:02:39,020 --> 00:02:43,930
Next one is that function can improve the performance of your code.

44
00:02:43,940 --> 00:02:50,870
Well, this is advanced level part of because when it comes to Y JavaScript, Y JavaScript, I mean

45
00:02:50,870 --> 00:02:52,250
run behind the scene.

46
00:02:52,280 --> 00:02:57,630
If you get a function, it is to go into the memory of JavaScript by that is advanced part.

47
00:02:57,650 --> 00:02:58,430
Don't worry about that.

48
00:02:58,430 --> 00:03:00,980
So this one, I'll give it as question mark.

49
00:03:01,850 --> 00:03:05,660
The next part is that functions can help to modernize your code.

50
00:03:05,660 --> 00:03:06,380
Meaning.

51
00:03:07,370 --> 00:03:13,250
We can copy certain certain code together at one place to mobilize it.

52
00:03:13,400 --> 00:03:15,350
The next one is that it.

53
00:03:15,350 --> 00:03:17,840
Is this more it helps for?

54
00:03:18,830 --> 00:03:21,050
Testing and improved testing.

55
00:03:21,560 --> 00:03:22,820
That was an advanced part of it.

56
00:03:22,850 --> 00:03:31,580
So in short, functions should be reusable, meaning it can any way I want I can just visit and then

57
00:03:31,580 --> 00:03:35,600
a function might contain a piece of logic in your application.

58
00:03:35,990 --> 00:03:40,460
But right now we don't have all those things that our function is doing right now.

59
00:03:40,520 --> 00:03:45,350
So in this video, let's talk about parameters and argument.

60
00:03:45,590 --> 00:03:49,420
And then after that, we talk about what is called return keyword.

61
00:03:49,430 --> 00:03:53,720
After you go through that, then a function, the whole of this.

62
00:03:53,720 --> 00:03:55,460
Why a function?

63
00:03:55,460 --> 00:03:57,230
This particular function we meet.

64
00:03:57,350 --> 00:04:00,350
So let's see in the next video, guys.

