1
00:00:00,240 --> 00:00:04,410
Let me show you how I'm going to solve this particular challenge.

2
00:00:04,770 --> 00:00:12,600
So coming down here, let me copy the question again and then place it down here because I want to make

3
00:00:12,600 --> 00:00:13,650
reference to it.

4
00:00:14,250 --> 00:00:16,290
After that, I'm going to remove it.

5
00:00:16,500 --> 00:00:25,230
So the first question is that create a function to separate a string using any character and the functions

6
00:00:25,230 --> 00:00:25,920
we take to.

7
00:00:26,550 --> 00:00:32,640
The first argument is the array, and the second argument is a character to use as a separator.

8
00:00:32,880 --> 00:00:37,050
So let's see how I'm going to solve this particular challenge.

9
00:00:37,380 --> 00:00:41,200
So the first one says that I should provide my function name.

10
00:00:41,250 --> 00:00:42,450
The first statement.

11
00:00:42,720 --> 00:00:44,010
So solution.

12
00:00:47,740 --> 00:00:48,550
It goes like this.

13
00:00:48,550 --> 00:00:56,170
So I'm going to use function expression so it counts and I will name my function as separate.

14
00:00:57,240 --> 00:00:57,930
String.

15
00:00:58,680 --> 00:01:04,379
And now e go to my function keyword and my parentheses and my carry braces.

16
00:01:04,680 --> 00:01:12,060
So point about to say that the functions we take to activate the first I given is the array, so provide

17
00:01:12,060 --> 00:01:15,180
an array as my parameter here.

18
00:01:15,420 --> 00:01:17,400
The second element is a character.

19
00:01:17,400 --> 00:01:18,960
So here, come on.

20
00:01:18,960 --> 00:01:20,730
And then my character.

21
00:01:21,240 --> 00:01:24,150
So now here comes the logic.

22
00:01:24,900 --> 00:01:32,490
Well, you remember that on array we can use join to join with a different character.

23
00:01:32,940 --> 00:01:39,180
So if the question says that we should pass in a string, then we're going to make our life a little

24
00:01:39,180 --> 00:01:39,780
bit difficult.

25
00:01:39,780 --> 00:01:40,830
But here is the case.

26
00:01:40,830 --> 00:01:44,490
You should walk, pass in an array, and that is it.

27
00:01:44,760 --> 00:01:45,480
So let's see.

28
00:01:45,480 --> 00:01:48,780
So here is going to return the array.

29
00:01:48,780 --> 00:01:57,000
I'll pass in as an argument to this function on that I have the method called join on that and I want

30
00:01:57,000 --> 00:02:00,660
to join with the character or passing to this function.

31
00:02:00,660 --> 00:02:02,820
So here we go.

32
00:02:02,820 --> 00:02:10,590
So down here let me assign the result coming back after calling this function called separate string

33
00:02:10,919 --> 00:02:17,730
and we see that look at IntelliSense, the this particular function takes in an array and then a character

34
00:02:17,730 --> 00:02:18,180
here.

35
00:02:18,690 --> 00:02:22,380
So here I'll provide an array of record.

36
00:02:22,410 --> 00:02:31,050
Let me call this one, let's say JavaScript and then comma and then code CSS and then come on, let

37
00:02:31,050 --> 00:02:32,250
me provide this say.

38
00:02:32,610 --> 00:02:33,300
JS.

39
00:02:33,990 --> 00:02:39,930
The next agreement our pass in is a character I want to use separate this array.

40
00:02:39,960 --> 00:02:42,660
So comma here come on.

41
00:02:42,660 --> 00:02:44,730
And then I want to separate with dash.

42
00:02:45,060 --> 00:02:46,110
So let's see.

43
00:02:46,110 --> 00:02:48,960
So now let me console.log the result.

44
00:02:51,130 --> 00:02:52,420
So check the console.

45
00:02:52,420 --> 00:02:59,710
Now we see that it has been separated with the dash because the last record is lost.

46
00:02:59,710 --> 00:03:01,270
We don't have the dash in front of it.

47
00:03:02,110 --> 00:03:04,210
So that is about the first challenge.

48
00:03:04,570 --> 00:03:11,890
The second one is a little bit difficult than the first one because we need to do some level of some

49
00:03:11,890 --> 00:03:12,550
logic here.

50
00:03:12,970 --> 00:03:18,310
So now let me remove this question, this comment here.

51
00:03:19,690 --> 00:03:22,720
Save it and now I'm done with the first one.

52
00:03:23,350 --> 00:03:23,800
Yeah.

53
00:03:23,800 --> 00:03:24,670
The second challenge.

54
00:03:24,670 --> 00:03:25,560
So let me copy this.

55
00:03:25,570 --> 00:03:33,430
You can challenge also let me call this one solution one and down here going to be as solution to.

56
00:03:35,210 --> 00:03:36,650
So listen up.

57
00:03:39,100 --> 00:03:39,710
Two.

58
00:03:40,030 --> 00:03:42,600
So let's read the question again.

59
00:03:42,610 --> 00:03:47,500
And it is that create a function to reverse a string.

60
00:03:47,830 --> 00:03:52,270
Remember you to reverse a string, but not an array.

61
00:03:52,930 --> 00:03:57,670
So the next point is that the function should take a string as an argument.

62
00:03:57,880 --> 00:04:02,140
The function should return the string in reverse order.

63
00:04:02,380 --> 00:04:07,540
So here we ask ourselves, what kind of method do we need for this?

64
00:04:07,600 --> 00:04:10,720
Well, it talks about what reverse we need.

65
00:04:10,720 --> 00:04:12,430
What a reverse method.

66
00:04:12,490 --> 00:04:15,020
And reverse method works on array.

67
00:04:15,040 --> 00:04:17,930
But the question is that we should pass in a string.

68
00:04:17,950 --> 00:04:23,560
So it means that we need to use split and split the text into an array.

69
00:04:23,590 --> 00:04:28,030
Then I can use reverse and then join it with a different character.

70
00:04:28,270 --> 00:04:30,250
So let me show you what I'm going to do right now.

71
00:04:30,670 --> 00:04:37,840
So coming down here, I'm going to name my function and use some function statement here for function

72
00:04:37,850 --> 00:04:48,700
here is going to be as reverse reverse string once reverse the string and then pass in only the string

73
00:04:48,700 --> 00:04:50,320
I want to reverse.

74
00:04:50,560 --> 00:04:52,750
And now my carry braces.

75
00:04:52,930 --> 00:04:55,030
So here we go.

76
00:04:55,150 --> 00:05:04,600
So inside, I'm going to return the string zero dot splits because I need to split it before I can get

77
00:05:04,600 --> 00:05:05,320
an array.

78
00:05:05,770 --> 00:05:12,250
So if I split it into individual component, split with the empty string like that.

79
00:05:12,610 --> 00:05:19,480
And then because after splitting, I get an array so I can change it again, code chain, I can change

80
00:05:19,510 --> 00:05:21,520
as many methods as I want.

81
00:05:21,820 --> 00:05:26,830
So on that, I can also change what is called the reverse.

82
00:05:27,640 --> 00:05:28,990
The reverse.

83
00:05:29,830 --> 00:05:30,670
I want to reverse it.

84
00:05:30,670 --> 00:05:36,100
And after that, I want to join with what let's say empty string as that.

85
00:05:36,100 --> 00:05:37,050
So that is it.

86
00:05:37,060 --> 00:05:38,510
So let's try it out and see.

87
00:05:38,530 --> 00:05:41,100
So coming down here const.

88
00:05:41,110 --> 00:05:43,150
So let me comment out this one here.

89
00:05:44,120 --> 00:05:45,200
There is a lot here.

90
00:05:46,310 --> 00:05:49,330
So coming down here comes cost.

91
00:05:50,240 --> 00:05:58,160
My result is equal to reverse string and I'll pass in a string I want to reverse.

92
00:05:58,160 --> 00:06:01,700
So let's say that I want to reverse.

93
00:06:01,700 --> 00:06:05,060
I mean, node node.js, save it.

94
00:06:05,690 --> 00:06:12,920
Okay, so now let's console.log the result down here as mine result and now let's have a look.

95
00:06:14,240 --> 00:06:23,840
I have reversed it to have something like Node J is in this way j you g don't a sg don't.

96
00:06:23,960 --> 00:06:26,780
So that's how we can reverse it, right?

97
00:06:26,780 --> 00:06:31,160
So if this syntax confuses you, let me break it down a little bit here.

98
00:06:31,400 --> 00:06:33,800
So here because something changed.

99
00:06:33,830 --> 00:06:38,810
So like I said, we can change us any methods we want.

100
00:06:38,810 --> 00:06:43,460
So first of all, we can say that, okay, so let me remove let me have comments here.

101
00:06:43,730 --> 00:06:45,590
First of all, convex.

102
00:06:46,910 --> 00:06:53,540
Convex trying to array the first one so counts string.

103
00:06:54,560 --> 00:06:56,580
Eric is equal to.

104
00:06:56,660 --> 00:07:05,690
I would take the string and then on that split the first one and then after splitting I want to reverse

105
00:07:05,690 --> 00:07:05,810
it.

106
00:07:05,810 --> 00:07:07,430
So reverse.

107
00:07:09,170 --> 00:07:11,330
The convicted.

108
00:07:13,100 --> 00:07:14,230
I strength.

109
00:07:16,350 --> 00:07:17,350
Convective string.

110
00:07:17,370 --> 00:07:17,820
Yeah.

111
00:07:18,000 --> 00:07:18,930
More precise.

112
00:07:19,500 --> 00:07:20,340
Is that so?

113
00:07:20,340 --> 00:07:24,540
Here counts as reverse.

114
00:07:27,200 --> 00:07:27,940
I read.

115
00:07:29,080 --> 00:07:32,200
It is reversed, Harry.

116
00:07:32,830 --> 00:07:34,970
And because now it's an array.

117
00:07:34,990 --> 00:07:42,580
I can have the this one and then t are array dot.

118
00:07:44,020 --> 00:07:44,830
Reverse.

119
00:07:46,430 --> 00:07:47,180
As that.

120
00:07:47,330 --> 00:07:53,510
But guys, because we are within cost here, we cannot overwrite this particular data.

121
00:07:53,510 --> 00:07:56,840
So let's use let's as we discuss under the.

122
00:07:58,390 --> 00:07:59,680
JavaScript types.

123
00:07:59,680 --> 00:08:06,700
So now I have joined it the Nest app, reverse it at a reverse and I want to so let's remove this and

124
00:08:06,700 --> 00:08:15,070
for now let's try to remove this one and then let's return the reverse string and let's see if we see

125
00:08:15,070 --> 00:08:15,370
that.

126
00:08:15,370 --> 00:08:23,050
I guess something where here is sorry is reverse array this one it will see that I have the reverse

127
00:08:23,050 --> 00:08:25,780
array, but how can I join it?

128
00:08:25,990 --> 00:08:32,679
So if I use join, I'm going to remove this array and I'm going to have this text.

129
00:08:32,679 --> 00:08:36,250
So here I can append dot join.

130
00:08:37,730 --> 00:08:38,600
As that.

131
00:08:39,470 --> 00:08:42,130
And now I have it as before.

132
00:08:42,140 --> 00:08:44,960
So here we can even go one level and say that.

133
00:08:44,960 --> 00:08:49,000
Let the definer agree.

134
00:08:49,010 --> 00:08:50,450
Let me say a array.

135
00:08:51,290 --> 00:08:52,070
Find out.

136
00:08:52,070 --> 00:08:53,510
Let me say finite string.

137
00:08:54,860 --> 00:09:06,050
Finite string is not equal to my reverse my reverse array, which is this one then dot join.

138
00:09:07,490 --> 00:09:10,940
Then I can return the final year.

139
00:09:14,200 --> 00:09:16,230
And then it's still the same.

140
00:09:16,240 --> 00:09:19,330
So any of the other methods also.

141
00:09:19,360 --> 00:09:22,870
Okay, so here are simple one line of code I can just return.

142
00:09:22,870 --> 00:09:28,900
So let me comment out this once and then this one can be shortened using the return.

143
00:09:28,900 --> 00:09:31,240
I would take my string on that.

144
00:09:31,240 --> 00:09:35,290
I'm going to just play it to split it with empty string.

145
00:09:35,320 --> 00:09:37,600
After that, I want to reverse it.

146
00:09:38,470 --> 00:09:39,310
Reverse.

147
00:09:41,400 --> 00:09:42,180
Reverse.

148
00:09:42,180 --> 00:09:43,650
And then after reversing.

149
00:09:43,650 --> 00:09:44,790
I want to join it.

150
00:09:45,360 --> 00:09:45,960
So.

151
00:09:47,010 --> 00:09:47,640
Let's see.

152
00:09:47,670 --> 00:09:48,150
Let's go.

153
00:09:48,240 --> 00:09:49,200
Empty string.

154
00:09:49,440 --> 00:09:51,090
And now I have it.

155
00:09:51,090 --> 00:09:53,430
So any of this one is fine.

