1
00:00:00,480 --> 00:00:04,080
In this video, we will talk about splits.

2
00:00:05,190 --> 00:00:13,050
Join and then reverse because we may need this concept to be able to solve the upcoming coding challenge.

3
00:00:13,050 --> 00:00:15,870
So let's start with split well.

4
00:00:15,870 --> 00:00:19,920
So let's comment out where we left in the previous video.

5
00:00:20,490 --> 00:00:24,690
Now the first concept is going to be split.

6
00:00:27,020 --> 00:00:27,680
So what?

7
00:00:27,680 --> 00:00:36,890
Actually, a split is where the split method separates a string into an array of substring, which means

8
00:00:36,890 --> 00:00:45,440
that if you use a split on a string, it's going to slice it, let me say, or break down the individual

9
00:00:45,440 --> 00:00:49,760
characters in the separate component and then put it inside an array.

10
00:00:50,090 --> 00:00:52,640
So let's have some example to show you.

11
00:00:52,760 --> 00:00:59,570
So let's say this my variable, my string is equal to, equal to, let's say you.

12
00:01:00,110 --> 00:01:01,850
Yes, it's like that.

13
00:01:02,060 --> 00:01:10,080
So on that let's declare a variable called response and then it's equal to str my string and then dot

14
00:01:10,130 --> 00:01:10,880
splits.

15
00:01:11,360 --> 00:01:17,210
So if I do that now let's try to console that log the response here.

16
00:01:17,210 --> 00:01:22,040
So let me open up, let me open the console.

17
00:01:22,070 --> 00:01:27,320
You can see that it has taken the string and put it inside an array.

18
00:01:28,190 --> 00:01:34,490
If you're not familiar with an array, we have a specific session to dive more about array.

19
00:01:34,760 --> 00:01:40,880
So you can see that we have the text inside an array, but we haven't finished the implementation.

20
00:01:41,060 --> 00:01:50,150
If you pass in quotation mark empty string, we see that it has what, break down the actual text into

21
00:01:50,150 --> 00:01:56,300
substring, meaning the individual characters, and then it has been separated with this comma by default.

22
00:01:56,330 --> 00:02:03,620
So we see that we have you y o and you with different main characters in the array.

23
00:02:03,890 --> 00:02:12,740
So for this one we can access the first character using the array index of zero because arrays are zero

24
00:02:12,740 --> 00:02:13,190
based.

25
00:02:13,190 --> 00:02:17,900
If I save it, I get why we're not diving more about array.

26
00:02:17,930 --> 00:02:25,330
The whole logic or idea I want to make it aware of is that a split take a string and then break down

27
00:02:25,370 --> 00:02:28,910
the individual characters and put it inside an array.

28
00:02:28,910 --> 00:02:30,710
So that is the split.

29
00:02:30,710 --> 00:02:35,150
So you may need this concept to be able to solve the upcoming coding challenge.

30
00:02:35,330 --> 00:02:39,350
So the next method that we talk about is what you call join.

31
00:02:39,350 --> 00:02:45,140
So let me have some enough room here and now let me comment out this one.

32
00:02:45,740 --> 00:02:52,370
So the next concept, I can copy this one here and now, paste it here, change this one to join.

33
00:02:52,550 --> 00:02:54,350
So what drawing does?

34
00:02:54,350 --> 00:02:59,510
Well, the joint methods retains an array converted into a string.

35
00:02:59,900 --> 00:03:03,860
So the joint, the joint method does not change the original array.

36
00:03:03,980 --> 00:03:14,450
So here too, you can see that if you use plates on the string, it put them into an array and for join

37
00:03:14,510 --> 00:03:16,520
it also operates on array.

38
00:03:16,520 --> 00:03:22,760
But you're going to convert those individual characters to form actual words and then convert that one

39
00:03:22,760 --> 00:03:23,870
into a string.

40
00:03:24,110 --> 00:03:26,120
So let me show you here.

41
00:03:26,420 --> 00:03:34,310
So remember the array joint works on array, but because we haven't talked about arrays now for this

42
00:03:34,310 --> 00:03:42,650
method that we have here, remember that when I console.log the the rest I have the array here.

43
00:03:43,130 --> 00:03:49,700
So for this I can use join or need to join the individual characters.

44
00:03:49,700 --> 00:03:55,880
So like I said, pay attention to what I'm going to do here because you need this idea to solve the

45
00:03:55,880 --> 00:03:57,410
upcoming coding challenge.

46
00:03:57,500 --> 00:03:58,780
So join.

47
00:03:58,790 --> 00:04:03,020
So I need to take the response I get back, which is response here.

48
00:04:03,020 --> 00:04:06,920
So response dot join in the group.

49
00:04:06,920 --> 00:04:13,160
What I like about this is that you can join with any character or any delimiter here.

50
00:04:13,190 --> 00:04:16,730
So let's remove the console.log here and let's bring it down here.

51
00:04:16,760 --> 00:04:26,600
So let's assign the result after joining into a variable core convective converter string, so equal

52
00:04:26,600 --> 00:04:27,230
to that.

53
00:04:27,470 --> 00:04:37,100
So for this, if I console.log the contact string, this one you could see that I have what you it has

54
00:04:37,100 --> 00:04:44,150
remove the I mean the array if you don't passing anything inside the joint by default.

55
00:04:44,150 --> 00:04:51,860
We have been separated by this by photons join them together we pass in empty string like that and we

56
00:04:51,860 --> 00:04:54,440
see that each has joined them together.

57
00:04:54,770 --> 00:04:59,260
And you may be thinking that, well, can I join with different characters or a different symbol?

58
00:04:59,270 --> 00:04:59,720
Yes.

59
00:04:59,720 --> 00:05:03,410
So let's say that you want to join with some special character.

60
00:05:03,410 --> 00:05:05,720
So here we can use comma here.

61
00:05:05,720 --> 00:05:08,090
That's by default, that's what we have.

62
00:05:08,450 --> 00:05:16,220
And then I can also join them using this underscore and now I have that you has been joined using this

63
00:05:16,220 --> 00:05:20,630
symbol and I can join with any character present sign.

64
00:05:20,660 --> 00:05:21,470
I have it.

65
00:05:21,470 --> 00:05:25,430
I can join with, let's say division sign.

66
00:05:25,550 --> 00:05:26,350
I can have it now.

67
00:05:26,410 --> 00:05:30,730
I believe you know where we are heading towards about our coding challenge that is coming.

68
00:05:30,730 --> 00:05:31,300
Right.

69
00:05:31,300 --> 00:05:36,460
So the next concept that we are going to talk about is what you call race.

70
00:05:36,670 --> 00:05:44,260
Well, so now you know the joint method, the method works on array, it is the array and then convert

71
00:05:44,260 --> 00:05:50,460
the the characters into single string and then we can separate them with the special characters.

72
00:05:50,470 --> 00:05:53,910
So the next concept is going to be us reverse.

73
00:05:54,520 --> 00:06:00,610
So let me copy this one, paste it here, and it's going to be as reverse.

74
00:06:01,810 --> 00:06:02,260
Perfect.

75
00:06:02,260 --> 00:06:03,500
So what is a reverse?

76
00:06:03,520 --> 00:06:11,590
Well, the reverse method changes the order of the element in an array so that the first element becomes

77
00:06:11,590 --> 00:06:16,690
the last and the second element become the second to the last and so on and so forth.

78
00:06:17,080 --> 00:06:22,770
Well, one cool thing is that the reverse method does not modify the original array.

79
00:06:23,020 --> 00:06:26,860
So again, the reverse also works on an array.

80
00:06:26,950 --> 00:06:32,080
So for the meantime, let's have some record here counts.

81
00:06:32,080 --> 00:06:35,920
Let's say I'm going to list some list of food equal to an array.

82
00:06:35,950 --> 00:06:39,720
So like I said, we have a specific such an array.

83
00:06:39,730 --> 00:06:46,600
So here I will say that the food I like best one is pizza and one is called congee.

84
00:06:48,460 --> 00:06:49,330
Kanji.

85
00:06:49,330 --> 00:06:52,150
And then I was like, What is kung fu fu?

86
00:06:52,510 --> 00:06:56,830
And then the next food I like best is also called rice.

87
00:06:56,860 --> 00:06:57,380
Good.

88
00:06:57,400 --> 00:06:59,920
So now how can I reverse the order?

89
00:07:00,010 --> 00:07:04,210
So if I consider that look, let me have on one line.

90
00:07:04,240 --> 00:07:04,780
Good.

91
00:07:04,990 --> 00:07:07,300
If I console.log food here.

92
00:07:07,300 --> 00:07:08,830
Let's see the food here.

93
00:07:09,040 --> 00:07:09,610
You see that?

94
00:07:09,610 --> 00:07:15,670
I have the food inside my console.log with the same order that has been stated here.

95
00:07:15,820 --> 00:07:22,430
So if I want the rice to become first and then pizza in that order, how am I going to do it?

96
00:07:22,450 --> 00:07:25,290
That's why we need the reverse method.

97
00:07:25,300 --> 00:07:29,230
So const, let's say, reversed.

98
00:07:30,360 --> 00:07:37,140
Reversed strength or reverse array is equal to food.

99
00:07:37,860 --> 00:07:41,430
My foot variable on that dot reverse.

100
00:07:42,500 --> 00:07:43,400
Reverse.

101
00:07:44,170 --> 00:07:45,910
And is that so?

102
00:07:46,270 --> 00:07:51,130
If I could answer that, log the reverse array.

103
00:07:52,570 --> 00:07:53,860
Reverse area.

104
00:07:54,640 --> 00:07:57,160
So let's see that it has been reversed.

105
00:07:57,190 --> 00:08:01,420
Now the rice has become first, but here rice is sliced.

106
00:08:01,420 --> 00:08:07,810
But because I have reversed it, I have rice first, and then the food now becomes second and congee

107
00:08:07,810 --> 00:08:11,080
becomes third and then PC becomes last.

108
00:08:11,080 --> 00:08:21,940
So remember that the reverse reverse the entire order of an array and then the joint takes an array

109
00:08:21,940 --> 00:08:28,900
and then you can join with any special characters and as played takes in a string and then convert into

110
00:08:28,900 --> 00:08:29,620
an array.

111
00:08:29,740 --> 00:08:34,630
So with this concept in this video, let's start with our first coding challenge.

