1
00:00:00,789 --> 00:00:04,345
Let's see arrow functions in action in our

2
00:00:04,345 --> 00:00:06,504
demo. We'll begin with defining a regular

3
00:00:06,504 --> 00:00:09,539
function to add two numbers, and then

4
00:00:09,539 --> 00:00:12,289
change it to use arrow functions. First,

5
00:00:12,289 --> 00:00:15,589
let's define our sum function. It takes

6
00:00:15,589 --> 00:00:18,075
two input parameters, and returns their

7
00:00:18,075 --> 00:00:21,456
sum in the body. We then invoke the sum

8
00:00:21,456 --> 00:00:24,234
function with arguments 10 and 5, and

9
00:00:24,234 --> 00:00:27,345
assign the return value to the variable

10
00:00:27,345 --> 00:00:30,900
output. We then log the output value to

11
00:00:30,900 --> 00:00:34,706
the console. As you can see, the value 15

12
00:00:34,706 --> 00:00:37,361
is displayed in the console. Now, let's

13
00:00:37,361 --> 00:00:40,589
follow the steps to change this into an

14
00:00:40,589 --> 00:00:43,123
arrow function. First, we remove the

15
00:00:43,123 --> 00:00:45,789
function keyword and the function name.

16
00:00:45,789 --> 00:00:49,678
Then, let's create a variable sum to hold

17
00:00:49,678 --> 00:00:52,789
the value returned by the arrow function.

18
00:00:52,789 --> 00:00:55,075
Next, we add the equal sign, immediately

19
00:00:55,075 --> 00:00:57,389
followed by the greater than sign before

20
00:00:57,389 --> 00:01:00,589
the opening curly brace. Now, since

21
00:01:00,589 --> 00:01:02,989
there's only one statement inside the

22
00:01:02,989 --> 00:01:05,456
function body, we can delete the return

23
00:01:05,456 --> 00:01:07,789
keyword, as well as the opening and

24
00:01:07,789 --> 00:01:10,289
closing curly braces, and move everything

25
00:01:10,289 --> 00:01:13,389
on one line. Finally, we invoke the

26
00:01:13,389 --> 00:01:16,789
function with values 10 and 7, and save.

27
00:01:16,789 --> 00:01:21,000
As you can see, the value 17 is now displayed in the console.

