1
00:00:01,060 --> 00:00:01,990
In this video.

2
00:00:01,990 --> 00:00:07,450
Let's talk about another property and methods that we can use to operate on strings.

3
00:00:07,780 --> 00:00:13,260
So in this video, we will talk about three of the methods because they are simple to use.

4
00:00:13,270 --> 00:00:19,590
And after that we're going to have our another coding challenge or have a coding challenge.

5
00:00:19,600 --> 00:00:20,980
So let's comment out.

6
00:00:20,980 --> 00:00:23,850
This one's the one we solved here.

7
00:00:23,860 --> 00:00:24,460
This one.

8
00:00:24,700 --> 00:00:25,330
So.

9
00:00:25,840 --> 00:00:26,020
Okay.

10
00:00:26,110 --> 00:00:28,900
I can leave it because I'm not console.log anything here.

11
00:00:29,290 --> 00:00:34,720
So here the methods that we are going to talk about right now is what let me have.

12
00:00:35,320 --> 00:00:37,420
The first one is called trim.

13
00:00:38,760 --> 00:00:41,430
And then next I'm going to be to.

14
00:00:43,630 --> 00:00:46,960
Uppercase and then to.

15
00:00:48,600 --> 00:00:55,170
Lowercase and then lowercase and then talk about index of.

16
00:00:55,820 --> 00:00:58,490
So let's start with the trim.

17
00:00:59,240 --> 00:01:00,580
So let's start with the trim.

18
00:01:00,590 --> 00:01:09,220
So the trim is used to remove wide spacing around a particular string that is from side by side.

19
00:01:09,230 --> 00:01:15,410
So like I explained to you before that we're not trying to find a length of a certain character.

20
00:01:15,410 --> 00:01:18,320
It takes the white spacing into consideration.

21
00:01:18,410 --> 00:01:23,180
So white spacing simply means that spacing around a particular text.

22
00:01:23,180 --> 00:01:24,710
So let me show you what I'm in here.

23
00:01:25,100 --> 00:01:27,410
Let's declare a variable cost.

24
00:01:27,410 --> 00:01:32,060
And let's say this My string is equal to quoting time.

25
00:01:34,170 --> 00:01:34,930
Like that.

26
00:01:34,950 --> 00:01:41,010
So for this one, there is no wide spacing because there is no space around the text here.

27
00:01:41,340 --> 00:01:41,930
Okay.

28
00:01:41,940 --> 00:01:49,440
So as soon as I bring some spacing here, this vertical wide spacing, if I save it, it's still there.

29
00:01:49,440 --> 00:01:50,010
Right.

30
00:01:50,190 --> 00:01:56,510
So to remove that, make sure you have some consistency in your data, in your application.

31
00:01:56,520 --> 00:01:58,900
You need to trim that particular test.

32
00:01:59,100 --> 00:01:59,730
You need to what?

33
00:01:59,730 --> 00:02:04,380
Sanitize it, scrutinize it to make it the way you want.

34
00:02:04,410 --> 00:02:08,400
So because of that, you're going to use a method called trim.

35
00:02:08,400 --> 00:02:15,480
So let me declare a variable core result is equal to my string and then trim.

36
00:02:16,130 --> 00:02:18,020
I have that as a method.

37
00:02:18,290 --> 00:02:18,840
Great.

38
00:02:18,860 --> 00:02:29,000
So now let me console.log this one console that log the SD or the original one like that and then dart

39
00:02:29,000 --> 00:02:29,750
length.

40
00:02:31,030 --> 00:02:32,050
That the first one.

41
00:02:32,710 --> 00:02:36,550
And then after I trim it, I want to find the results.

42
00:02:37,150 --> 00:02:40,350
The console log, the results dot lamp.

43
00:02:40,360 --> 00:02:43,690
I don't know whether indeed it has been trimmed.

44
00:02:43,690 --> 00:02:47,440
For the meantime, let's remove the method here.

45
00:02:47,470 --> 00:02:49,090
Let me show you something here.

46
00:02:49,780 --> 00:02:52,320
If I save it, you can see that.

47
00:02:52,330 --> 00:02:54,010
Have a look at differences here.

48
00:02:54,960 --> 00:03:00,890
If we see that for the first one that has peace in Syria as I'm facing here, but we cannot see how

49
00:03:01,020 --> 00:03:03,330
they can as well as push to the side.

50
00:03:04,380 --> 00:03:10,230
But after I trim it because I remove the white space and that's why I have it be on this side or look

51
00:03:10,230 --> 00:03:10,890
at this one.

52
00:03:11,010 --> 00:03:12,240
There's some space here.

53
00:03:12,450 --> 00:03:20,250
And as that, let me prove to you, well, this one is supposed to be here and then supposed to what?

54
00:03:20,250 --> 00:03:21,540
And here.

55
00:03:22,140 --> 00:03:28,110
But because this one has some white space and just push, it has a space and then push it to the side.

56
00:03:28,230 --> 00:03:30,780
So that is that is how the dream weighs.

57
00:03:30,780 --> 00:03:34,860
It's really I mean, nice method we need to understand.

58
00:03:35,100 --> 00:03:41,910
So again, if I want to find the length of this particular before Trymaine and then after Trymaine,

59
00:03:42,210 --> 00:03:48,750
let's see after Trymaine, we see that the first one, because I have some space in it, has given me

60
00:03:48,750 --> 00:03:51,870
16 characters, which is which is weird.

61
00:03:51,870 --> 00:03:57,930
And then this one after Trymaine, I got 16 characters, meaning I have trimmed five off.

62
00:03:58,080 --> 00:03:59,280
That's about a trim.

63
00:03:59,610 --> 00:04:04,230
The next one is so let me remove this one from here.

64
00:04:04,260 --> 00:04:05,390
I can comment out.

65
00:04:05,400 --> 00:04:08,230
Yeah, okay.

66
00:04:08,430 --> 00:04:09,210
Yeah, yeah.

67
00:04:09,570 --> 00:04:11,700
Let me comment out the next one.

68
00:04:11,700 --> 00:04:14,730
Let's talk about the two uppercase and to lowercase.

69
00:04:14,730 --> 00:04:17,490
As the name implies, it is to convert.

70
00:04:18,550 --> 00:04:24,210
A string from lowercase to uppercase and uppercase to lowercase and vice versa.

71
00:04:24,330 --> 00:04:29,970
So this one going to be to lowercase and to uppercase.

72
00:04:30,000 --> 00:04:33,120
So let's have the same text as code in time.

73
00:04:33,120 --> 00:04:35,310
So it comes code in times I'm around.

74
00:04:35,310 --> 00:04:37,160
Let me make it nice.

75
00:04:37,170 --> 00:04:38,370
I want to trim it.

76
00:04:39,000 --> 00:04:42,090
So let's say for the uppercase.

77
00:04:42,890 --> 00:04:46,110
So let me console.log quickly here, because it is a simple method.

78
00:04:46,130 --> 00:04:47,960
There's no time to waste on this one.

79
00:04:47,960 --> 00:04:50,060
And let's start with our coding challenge.

80
00:04:50,090 --> 00:04:55,100
So on a string I have a method called to lowercase.

81
00:04:56,200 --> 00:04:57,220
To.

82
00:04:58,640 --> 00:05:04,700
Lowercase and then if I save it, we see that it has converted everything to lowercase even though it

83
00:05:04,700 --> 00:05:05,280
is uppercase.

84
00:05:05,280 --> 00:05:10,730
So let me make everything uppercase here as codeine and then type.

85
00:05:11,840 --> 00:05:14,690
You see that test converted everything to lowercase.

86
00:05:14,780 --> 00:05:18,110
So four lowercase h two lowercase.

87
00:05:18,110 --> 00:05:21,080
So for uppercase the same as to.

88
00:05:23,040 --> 00:05:24,630
To uppercase.

89
00:05:24,990 --> 00:05:29,280
So if I change this one to everything, I mean lowercase, let's say coding.

90
00:05:31,780 --> 00:05:38,620
Accordion time if I save it, see that it has converted everything to uppercase.

91
00:05:38,740 --> 00:05:45,730
The last method we are going to use, then we start our coding challenge is what we call the index of.

92
00:05:48,500 --> 00:05:54,860
Because we need this logic before we can solve the we can solve the challenge of the coding.

93
00:05:55,250 --> 00:05:57,800
That's why I am explaining to you before we start with that.

94
00:05:57,800 --> 00:06:06,410
So index of well the index of is used to determine at which particular point a certain character appears

95
00:06:06,680 --> 00:06:07,660
or is.

96
00:06:07,670 --> 00:06:08,540
So let's say that.

97
00:06:08,540 --> 00:06:10,850
Let me bring back this string here.

98
00:06:11,040 --> 00:06:11,960
Call.

99
00:06:12,890 --> 00:06:14,870
Costs as are coding time.

100
00:06:14,900 --> 00:06:22,280
If I want to know at which index once the index simply means at which place that a particular character

101
00:06:22,370 --> 00:06:23,300
exists.

102
00:06:23,300 --> 00:06:27,260
We have a specific video to dive more about a race.

103
00:06:27,260 --> 00:06:29,240
For the meantime, just bear with me.

104
00:06:29,270 --> 00:06:38,750
So I rest I index base zero base meaning that is start from zero when you count 0123456, seven, eight,

105
00:06:38,750 --> 00:06:39,440
nine, ten.

106
00:06:39,440 --> 00:06:49,790
So let's find out what index that see okay so on the start my string dot index of now to find at which

107
00:06:49,790 --> 00:06:53,870
index does this C or K, so I'll pass in C.

108
00:06:54,780 --> 00:06:55,500
Like that.

109
00:06:55,620 --> 00:06:57,570
So let me console.log the results.

110
00:06:57,570 --> 00:06:59,220
So const.

111
00:07:00,370 --> 00:07:02,920
Results is equal to that.

112
00:07:04,390 --> 00:07:05,650
Is equal to that.

113
00:07:05,680 --> 00:07:06,130
Yes.

114
00:07:06,130 --> 00:07:09,700
So if I console.log the results.

115
00:07:09,760 --> 00:07:11,040
Let's see it.

116
00:07:11,050 --> 00:07:11,920
Okay.

117
00:07:11,950 --> 00:07:13,870
At index zero.

118
00:07:13,900 --> 00:07:14,710
That is it.

119
00:07:15,040 --> 00:07:19,600
So 4d404040.

120
00:07:19,600 --> 00:07:22,640
Here it occurred at index one.

121
00:07:22,660 --> 00:07:24,600
That's why we have it here.

122
00:07:24,610 --> 00:07:25,420
Remember?

123
00:07:25,870 --> 00:07:27,940
Index of r k sensitive.

124
00:07:27,940 --> 00:07:30,310
Meaning that this one is.

125
00:07:31,230 --> 00:07:35,340
Uppercase A lowercase C and you pass in uppercase C.

126
00:07:36,930 --> 00:07:38,730
We're going to have some strange results.

127
00:07:39,030 --> 00:07:40,910
You see that negative one.

128
00:07:40,920 --> 00:07:44,880
So if a value doesn't exist, it returns.

129
00:07:44,880 --> 00:07:46,710
What negative one?

130
00:07:46,800 --> 00:07:53,460
And we can make use of in this off to make a little of logic meaning if you're are trying to find if

131
00:07:53,460 --> 00:08:00,900
a certain letter appears in a maybe some characters or where appears in certain string to ten minus

132
00:08:00,900 --> 00:08:07,380
one, which doesn't exist, for example, we can have a list of uses and we want to search for a certain

133
00:08:07,410 --> 00:08:14,040
user if you pass in and that user doesn't exist, the index of is going to return negative one.

134
00:08:14,370 --> 00:08:17,040
So let's say that I want to find four time.

135
00:08:18,160 --> 00:08:19,560
Here if I save it.

136
00:08:19,570 --> 00:08:22,480
Yes, it's worked at index seven.

137
00:08:22,480 --> 00:08:23,590
Meaning it exists.

138
00:08:23,590 --> 00:08:24,790
That's why we have it here.

139
00:08:25,180 --> 00:08:34,299
So the key note here is that the index of always gives you a negative one if it doesn't exist and it

140
00:08:34,299 --> 00:08:38,799
gave it a number at where it occurred, if it exists.

141
00:08:39,130 --> 00:08:48,070
So on that note, let's have our first challenge under trim and index off in the next video.

