1
00:00:01,350 --> 00:00:04,290
Let's get started with string comparison.

2
00:00:04,440 --> 00:00:06,480
Well, so far we are down with that.

3
00:00:06,480 --> 00:00:13,170
Strength matters because right now I have opened the gateway for you and you can learn any methods that

4
00:00:13,170 --> 00:00:15,300
you want to use in your future project.

5
00:00:15,300 --> 00:00:23,160
And always they are always online around and then find the particular strain metallurgy you want to

6
00:00:23,160 --> 00:00:25,140
use in your future project.

7
00:00:25,230 --> 00:00:27,270
Well, so let's comment out this one.

8
00:00:27,300 --> 00:00:31,440
Let's start with a new concept which is called string comparison.

9
00:00:31,440 --> 00:00:35,760
Meaning how can you compare string together in this video?

10
00:00:35,790 --> 00:00:42,210
I'm going to expose to you sometimes how JavaScript behave the way we don't explain it, right?

11
00:00:42,210 --> 00:00:50,850
But here the case you have no option unless you would be more about JavaScript before we can understand

12
00:00:50,850 --> 00:00:53,550
sometimes the weird things about JavaScript.

13
00:00:53,760 --> 00:00:57,990
So in this video, let's see how we can compare strings together.

14
00:00:57,990 --> 00:01:00,450
That's what you call strain comparison.

15
00:01:00,600 --> 00:01:02,640
So let me comment here.

16
00:01:04,000 --> 00:01:06,250
And then, let's say string.

17
00:01:07,630 --> 00:01:08,770
Comparison.

18
00:01:11,520 --> 00:01:12,150
Comparison.

19
00:01:12,150 --> 00:01:12,810
Yes.

20
00:01:16,480 --> 00:01:17,170
Good.

21
00:01:17,200 --> 00:01:24,940
So in order to compare whether one strain is more than the other, JavaScript employs what is known

22
00:01:24,940 --> 00:01:28,990
as dictionary or lexical graphical order.

23
00:01:29,500 --> 00:01:34,870
In other words, strings are compared by letter by letter.

24
00:01:34,900 --> 00:01:37,800
Let's see ways of comparing strings.

25
00:01:37,810 --> 00:01:41,090
For the meantime, let's compare letters together.

26
00:01:41,110 --> 00:01:44,080
So let's consider that log this.

27
00:01:44,290 --> 00:01:58,480
And now let's say that that's a less than B, if I save it, I got true because B comes after A.

28
00:01:58,510 --> 00:02:02,950
So it means that B is more than A the first point.

29
00:02:03,040 --> 00:02:10,870
The next point is, let me copy this one and then let's compare with the same letters, but different.

30
00:02:11,550 --> 00:02:12,510
Sheep, for example.

31
00:02:12,520 --> 00:02:14,880
One is uppercase and one is lowercase.

32
00:02:14,880 --> 00:02:16,020
So let's comment on this one.

33
00:02:16,020 --> 00:02:22,610
This one means that the the one that comes after the other is heavier.

34
00:02:22,620 --> 00:02:31,650
So A is a list followed by B, C, D, and the rest with Z is the highest if you are comparing the both

35
00:02:31,650 --> 00:02:33,330
lowercase together.

36
00:02:33,330 --> 00:02:41,610
So when I say Z here or sorry lowercase z here, I go through because Z is more than a like the first

37
00:02:41,610 --> 00:02:42,210
note.

38
00:02:42,210 --> 00:02:48,000
But the second point is that we see that they are of the same type, but one is uppercase and one is

39
00:02:48,000 --> 00:02:52,080
lowercase, so a is less than a uppercase.

40
00:02:52,110 --> 00:02:55,620
A Well, this is false.

41
00:02:55,620 --> 00:02:57,090
Always lowercase.

42
00:02:57,090 --> 00:03:00,090
R Heavier than the uppercase.

43
00:03:00,600 --> 00:03:03,000
Even there be more about this.

44
00:03:03,030 --> 00:03:04,970
I will leave some documentation for it.

45
00:03:04,990 --> 00:03:06,630
Read more about the order.

46
00:03:06,630 --> 00:03:13,890
How they appear in a certain scale, but for the mean time give you some simple fact about this logic.

47
00:03:14,160 --> 00:03:19,410
So the next point need to bear in mind is let's have one example here.

48
00:03:19,440 --> 00:03:25,230
Let's say I have blue and then here is GLY.

49
00:03:27,170 --> 00:03:27,950
Glee.

50
00:03:29,420 --> 00:03:32,480
Before we safe and sound.

51
00:03:33,050 --> 00:03:35,630
Can you tell me what the answer?

52
00:03:36,420 --> 00:03:37,110
Okay.

53
00:03:37,230 --> 00:03:38,190
Pause here.

54
00:03:38,460 --> 00:03:42,060
Let me give you some facts before we come back to this.

55
00:03:42,240 --> 00:03:49,890
Well, point number one is, bear in mind is that lower cases are more than upper cases.

56
00:03:50,220 --> 00:03:50,810
Okay.

57
00:03:50,820 --> 00:03:58,260
And we can determine where they are inside the internal encoding table of JavaScript.

58
00:03:58,260 --> 00:03:59,640
And that's a unique code.

59
00:03:59,910 --> 00:04:08,340
So if we want to learn more about this, we can go online and see which are where in the table or the

60
00:04:08,340 --> 00:04:10,470
internal table of JavaScript.

61
00:04:10,500 --> 00:04:11,800
That's this lettuce.

62
00:04:11,820 --> 00:04:12,390
Okay.

63
00:04:12,420 --> 00:04:18,120
For the meantime, let me give you the fact the simple way or summarize in a simple way would understand

64
00:04:18,120 --> 00:04:20,760
here without reading those documentation.

65
00:04:20,910 --> 00:04:26,460
So one point again is that lower cases are more than upper cases if they are of the same type.

66
00:04:27,150 --> 00:04:35,610
Point about two is that if they are of the same type, always the lower case is more than the other

67
00:04:35,610 --> 00:04:36,720
as like I said.

68
00:04:36,720 --> 00:04:44,340
And then the order a is the least followed by B, C, D, and the order z is the highest.

69
00:04:45,250 --> 00:04:51,730
So the next point is that if you are checking for letters like this one, like this one.

70
00:04:52,000 --> 00:04:56,190
So the first it would check the first letters on both sides.

71
00:04:56,200 --> 00:04:56,880
Checking.

72
00:04:56,890 --> 00:04:59,740
Yes, it's checking the first letters on both sides.

73
00:05:00,700 --> 00:05:04,150
If one is more than the other, it will return.

74
00:05:04,150 --> 00:05:04,800
True.

75
00:05:04,810 --> 00:05:11,650
But if they are equal you to move the next letter until it returns true or false.

76
00:05:12,130 --> 00:05:19,780
And lowercase are always more than the uppercase letters of the same type, because the lowercase character

77
00:05:19,780 --> 00:05:24,760
has a greater index in the internal encoding table of JavaScript.

78
00:05:24,940 --> 00:05:26,260
That is a unicode.

79
00:05:26,470 --> 00:05:31,540
So if both strains end at the same length, then they are equal.

80
00:05:31,570 --> 00:05:35,770
Otherwise the longer string is more.

81
00:05:36,490 --> 00:05:39,980
So let me let me let me show you that grammatically over here.

82
00:05:40,000 --> 00:05:42,910
First, I'm going to check both sides.

83
00:05:43,030 --> 00:05:45,190
Let's see if want to check.

84
00:05:45,190 --> 00:05:47,500
We have G and we have G.

85
00:05:47,620 --> 00:05:50,130
They are the same type, so they are equal.

86
00:05:50,140 --> 00:05:51,610
So you move the next letter.

87
00:05:51,730 --> 00:05:53,830
Small error and more error.

88
00:05:53,860 --> 00:05:56,110
Yes, they are equal now.

89
00:05:56,110 --> 00:05:58,090
Small and then small.

90
00:05:58,090 --> 00:06:00,790
E which one is heavier?

91
00:06:01,150 --> 00:06:01,870
Well.

92
00:06:02,760 --> 00:06:09,360
E comes after all or comes after E in the case.

93
00:06:11,050 --> 00:06:22,390
Or comes after e meaning that or is heavier than E therefore now this one is true.

94
00:06:22,630 --> 00:06:25,870
True here, and this one is false.

95
00:06:26,080 --> 00:06:35,950
So it means that glow is not less than glee because o is more than E, therefore the whole logic will

96
00:06:35,950 --> 00:06:38,670
exit and when to return the answer.

97
00:06:38,680 --> 00:06:43,870
So for this one, if I save it, for me it's going to return.

98
00:06:43,870 --> 00:06:46,960
False moment of truth.

99
00:06:47,770 --> 00:06:49,360
Yes, indeed.

100
00:06:49,360 --> 00:06:51,220
We have false over here.

101
00:06:51,930 --> 00:06:53,850
So that is it about that.

102
00:06:54,060 --> 00:06:59,480
So if I change, let's say this one to also us.

103
00:06:59,490 --> 00:07:00,060
Oh.

104
00:07:01,070 --> 00:07:03,110
Now we have uppercase.

105
00:07:03,260 --> 00:07:04,790
Then we have lowercase.

106
00:07:04,820 --> 00:07:10,280
Which one is going to retain the same thing or is heavier than this one?

107
00:07:10,280 --> 00:07:12,470
So same as what force?

108
00:07:12,470 --> 00:07:15,380
If I save it, I still see force.

109
00:07:15,560 --> 00:07:20,150
All right, so that's the basic explanation about how we can compare string together.

110
00:07:20,150 --> 00:07:21,200
So we are done with that.

111
00:07:21,200 --> 00:07:24,830
So let me bring it back to Glow and this one to us, Glow.

112
00:07:25,490 --> 00:07:25,940
Okay.

113
00:07:26,210 --> 00:07:31,110
The next comparison is comparison of different types.

114
00:07:31,130 --> 00:07:33,530
Let's see how we can compare.

115
00:07:33,950 --> 00:07:36,830
Compare string of different.

116
00:07:37,610 --> 00:07:38,390
Types.

117
00:07:38,720 --> 00:07:40,190
How is it possible?

118
00:07:40,430 --> 00:07:49,120
Well, when comparing values of different types, JavaScript convert the values to numbers and even

119
00:07:49,130 --> 00:07:49,760
more.

120
00:07:49,790 --> 00:07:51,320
And the numbers better.

121
00:07:51,320 --> 00:07:58,730
Understand this and remember that one to aim for this one we have talk about it about the equality,

122
00:07:58,730 --> 00:08:03,110
the double, and then the triple equals sign, how it works.

123
00:08:03,110 --> 00:08:05,480
So let's compare with different types.

124
00:08:05,480 --> 00:08:07,430
So let's console.log.

125
00:08:07,610 --> 00:08:13,280
Let's say a is more than I mean.

126
00:08:13,310 --> 00:08:14,360
Okay, let me say.

127
00:08:14,360 --> 00:08:17,510
Yeah, A is more than two.

128
00:08:17,630 --> 00:08:18,410
Let's see.

129
00:08:19,010 --> 00:08:20,090
No is force.

130
00:08:21,150 --> 00:08:23,190
A is never more than two here.

131
00:08:23,190 --> 00:08:25,440
So it's false here.

132
00:08:25,740 --> 00:08:27,170
So true.

133
00:08:27,180 --> 00:08:30,930
So if you're trying to compare this one, how is it possible?

134
00:08:30,930 --> 00:08:32,490
Why do we got false?

135
00:08:32,490 --> 00:08:36,809
Because two is more than a that's the first scenario here.

136
00:08:36,929 --> 00:08:45,690
The second scenario here is if you are trying to compare a string and number, again, let's see with

137
00:08:45,690 --> 00:08:46,800
this example.

138
00:08:47,430 --> 00:08:53,520
So let's say that I have here as five and then here also as five.

139
00:08:54,250 --> 00:08:57,880
How is it going to happen for this one if I save it?

140
00:08:57,970 --> 00:09:02,920
It is false because five is more than what this file.

141
00:09:02,950 --> 00:09:09,640
By default OC by default JavaScript behind this scene doing the convention for us.

142
00:09:10,860 --> 00:09:11,110
Okay.

143
00:09:11,340 --> 00:09:14,440
And would that be more about why this is okay?

144
00:09:14,460 --> 00:09:17,250
So if I also bring let's say.

145
00:09:18,210 --> 00:09:23,670
Though we quoted, what would be the answer going to be true if I say it?

146
00:09:23,820 --> 00:09:32,670
I got true because for equal sign it compared the values without taking into consideration the data

147
00:09:32,670 --> 00:09:34,350
type of the value.

148
00:09:34,740 --> 00:09:40,230
Because the data type of five is a string and this five is a number.

149
00:09:40,770 --> 00:09:45,680
So if we want to have strict comparison, we use triple equal two.

150
00:09:45,690 --> 00:09:49,920
Now I got false because a string can never be more.

151
00:09:49,920 --> 00:09:51,750
Cannot be equal to what five?

152
00:09:52,080 --> 00:09:53,880
There's one word in JavaScript.

153
00:09:53,880 --> 00:09:57,540
How can you compare a string to a string with a sign?

154
00:09:57,540 --> 00:10:03,510
And you say it is true, but behind the scene is doing the implicit I mean convention for us.

155
00:10:04,830 --> 00:10:10,440
Then what about comparing I mean Boolean values, comparing boolean values.

156
00:10:10,440 --> 00:10:13,860
So let's say comment out, not remove it.

157
00:10:13,890 --> 00:10:20,010
Comment out this and now let's compare Boolean values.

158
00:10:22,120 --> 00:10:24,310
So console.log.

159
00:10:25,420 --> 00:10:26,950
Is true.

160
00:10:29,160 --> 00:10:30,300
Equal to.

161
00:10:31,300 --> 00:10:32,060
One.

162
00:10:32,080 --> 00:10:32,890
Let's see.

163
00:10:33,600 --> 00:10:35,250
Yes, it is one.

164
00:10:35,340 --> 00:10:39,180
Because remember, if I bring triple equal to.

165
00:10:40,270 --> 00:10:43,360
I get force if I bring double equal to.

166
00:10:44,280 --> 00:10:47,910
I go true because always true.

167
00:10:48,300 --> 00:10:48,750
Always.

168
00:10:48,750 --> 00:10:57,540
What's not a false value is a true value and true value values start from one one, two, three, four

169
00:10:57,570 --> 00:11:00,220
and zero is what force value.

170
00:11:00,300 --> 00:11:03,180
So if I provide f here, force here.

171
00:11:03,950 --> 00:11:06,560
Frost here is going to be improve.

172
00:11:06,560 --> 00:11:11,900
Our force is always assigned a zero, so force is equal to zero meaning force.

173
00:11:11,960 --> 00:11:14,690
Okay, that's about a boolean comparison.

174
00:11:14,900 --> 00:11:24,920
So what about the last one is comparing with null and undefined now and undefined, let's say compare

175
00:11:25,040 --> 00:11:28,720
null and undefined.

176
00:11:28,730 --> 00:11:29,510
Let's see.

177
00:11:29,510 --> 00:11:31,340
Console.log.

178
00:11:31,670 --> 00:11:33,920
Let's I want to compare that now.

179
00:11:35,340 --> 00:11:37,890
Equal to undefined.

180
00:11:39,720 --> 00:11:40,510
Let's see.

181
00:11:40,530 --> 00:11:44,720
It is true because these ones have no values.

182
00:11:44,730 --> 00:11:50,070
But to make sure that you have a straight comparison you triple equal to.

183
00:11:50,100 --> 00:11:52,590
In that case, you're going to get false.

184
00:11:53,980 --> 00:11:56,320
So guys, that is simple.

185
00:11:56,320 --> 00:11:59,260
I mean, string comparison we can make.

186
00:11:59,440 --> 00:12:05,320
Well, the next video, let's start with a new topic called numbers.

