1
00:00:02,120 --> 00:00:03,460
Over the last lectures,

2
00:00:03,460 --> 00:00:06,810
I spent a lot of time on functions

3
00:00:06,810 --> 00:00:11,310
because functions are a super crucial and key feature

4
00:00:11,310 --> 00:00:14,260
which you will need all the time in JavaScript development

5
00:00:14,260 --> 00:00:16,590
and that's why you need to understand them.

6
00:00:16,590 --> 00:00:19,840
And I hope I could explain those key basics.

7
00:00:19,840 --> 00:00:22,410
We are going to write and use a lot of functions

8
00:00:22,410 --> 00:00:25,360
throughout this course so you will get a lot of practice,

9
00:00:25,360 --> 00:00:28,183
but the general idea should be clear by now.

10
00:00:29,090 --> 00:00:33,520
I wanna emphasize again that functions don't need to return

11
00:00:33,520 --> 00:00:36,210
and don't need to take parameters.

12
00:00:36,210 --> 00:00:38,960
It will depend on which kind of function you're writing

13
00:00:38,960 --> 00:00:40,840
and what it's doing.

14
00:00:40,840 --> 00:00:43,830
I also wanna emphasize again that functions of course

15
00:00:43,830 --> 00:00:46,450
can execute multiple steps in there

16
00:00:46,450 --> 00:00:50,250
and you can of course also introduce variables in there,

17
00:00:50,250 --> 00:00:55,250
like result, which then are only available in this function.

18
00:00:55,400 --> 00:01:00,010
And then here we could store userAge minus 18 and result

19
00:01:00,010 --> 00:01:03,520
and return the value stored and the result here.

20
00:01:03,520 --> 00:01:07,280
That would be an alternative way of writing this function,

21
00:01:07,280 --> 00:01:10,880
arguably an unnecessarily complex way,

22
00:01:10,880 --> 00:01:12,620
but to understand that you can do

23
00:01:12,620 --> 00:01:14,660
all these things and functions,

24
00:01:14,660 --> 00:01:18,140
I want to switch to that code for now.

25
00:01:18,140 --> 00:01:20,480
So which code goes into a function?

26
00:01:20,480 --> 00:01:25,150
And whether you return and/or whether you use parameters

27
00:01:25,150 --> 00:01:28,100
depends on what your function does.

28
00:01:28,100 --> 00:01:30,480
As I said, we're going to write many functions

29
00:01:30,480 --> 00:01:31,450
throughout this course,

30
00:01:31,450 --> 00:01:34,130
and therefore there will be plenty of opportunities

31
00:01:34,130 --> 00:01:36,070
to practice this.

32
00:01:36,070 --> 00:01:40,300
This is the general feature of functions.

33
00:01:40,300 --> 00:01:42,550
That's how it generally works.

34
00:01:42,550 --> 00:01:44,183
And now let's build up on that.

