1 00:00:00,390 --> 00:00:01,430 Welcome back. 2 00:00:01,430 --> 00:00:02,740 How did you do? 3 00:00:02,740 --> 00:00:04,810 If you had any trouble, don't worry. 4 00:00:04,810 --> 00:00:07,650 We're going to walk through how to rewrite each of these functions 5 00:00:07,650 --> 00:00:09,990 with arrow syntax right now. 6 00:00:09,990 --> 00:00:12,720 Let's with the first one, addToTen. 7 00:00:12,720 --> 00:00:17,680 This is a simple function that receives parameter num, adds num to 10 and 8 00:00:17,680 --> 00:00:18,650 then returns the sum. 9 00:00:19,740 --> 00:00:20,770 To begin, 10 00:00:20,770 --> 00:00:25,770 let's first replace the function keyword with variable declaration keyword, const. 11 00:00:26,880 --> 00:00:31,460 Then we add an equal sign, followed by the parameter that we're passing in. 12 00:00:31,460 --> 00:00:34,230 But remember, because we're only passing in one parameter, 13 00:00:34,230 --> 00:00:36,615 we don't need to enclose it in parentheses. 14 00:00:38,238 --> 00:00:42,327 After the parameter we type our arrow which points to the code inside our 15 00:00:42,327 --> 00:00:43,990 function. 16 00:00:43,990 --> 00:00:46,710 Since this function only includes one line of code, 17 00:00:46,710 --> 00:00:50,800 we don't need our curly braces and the entire expression can go on one line. 18 00:00:54,792 --> 00:00:58,367 We also don't need the return key word because arrow functions 19 00:00:58,367 --> 00:01:01,610 will implicitly return the value of one line functions. 20 00:01:02,620 --> 00:01:04,430 That was a lot to take in. 21 00:01:04,430 --> 00:01:08,260 If there were some things you didn't understand there, no worries. 22 00:01:08,260 --> 00:01:11,564 I recommend going back and reviewing the create functions using arrow 23 00:01:11,564 --> 00:01:14,140 syntax section of this course, before trying again. 24 00:01:14,140 --> 00:01:18,018 For our second function, divideUs, I'm gonna go ahead and 25 00:01:18,018 --> 00:01:20,460 copy in my solution to this function. 26 00:01:22,480 --> 00:01:23,130 The process for 27 00:01:23,130 --> 00:01:26,940 converting this function declaration to an arrow function expression, 28 00:01:26,940 --> 00:01:30,710 is almost exactly the same as our first example, except for one difference. 29 00:01:30,710 --> 00:01:31,980 Do you know what it is? 30 00:01:33,560 --> 00:01:35,050 Yep, you got it. 31 00:01:35,050 --> 00:01:39,260 This function receives two parameters, so they have to be enclosed with parentheses. 32 00:01:40,630 --> 00:01:43,540 Here's my solution for our final function, printMyName. 33 00:01:45,170 --> 00:01:49,720 Unlike the last two examples, this function doesn't take any parameters. 34 00:01:49,720 --> 00:01:54,650 Even so, we still have to notate this by including an empty set of parentheses 35 00:01:54,650 --> 00:01:56,380 after the equals sign. 36 00:01:56,380 --> 00:01:59,720 Also, because this function contains two lines of code, 37 00:01:59,720 --> 00:02:02,230 we have to keep our curly braces. 38 00:02:02,230 --> 00:02:03,490 So there you have it. 39 00:02:03,490 --> 00:02:06,390 You just converted three regular function declarations to 40 00:02:06,390 --> 00:02:07,950 arrow function expressions. 41 00:02:07,950 --> 00:02:08,540 Great job. 42 00:02:09,570 --> 00:02:14,310 Let's move on now to our second file, refactor.js. 43 00:02:14,310 --> 00:02:18,410 Inside this file, there are three functions written with arrow syntax. 44 00:02:18,410 --> 00:02:21,375 Your goal for this part of the practice session, is to try and 45 00:02:21,375 --> 00:02:26,380 refactor these functions so they are as short and concise as the syntax allows. 46 00:02:26,380 --> 00:02:30,600 Just a hint, one of these might already be as concise as possible. 47 00:02:30,600 --> 00:02:33,300 Give this a go and we'll regroup later to go over the solution.