Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,390 --> 00:00:06,570
Now these symbols, such as the greater or the lesser than or the three equals signs, are known in programming
2
00:00:06,600 --> 00:00:10,890
as comparatives because they allow us to compare two different values.
3
00:00:10,980 --> 00:00:13,760
So we've seen and used the three equals signs.
4
00:00:13,950 --> 00:00:19,600
And this is checking whether if the left hand side is equal to the right hand side.
5
00:00:19,830 --> 00:00:26,370
Now you can also use a exclamation mark and two equal signs to check whether if the left hand side is
6
00:00:26,370 --> 00:00:32,340
not equal to the right hand side, as well as whether if something is greater then something else or something
7
00:00:32,340 --> 00:00:37,050
is lesser than something else or greater than equal or lesser than equal.
8
00:00:37,080 --> 00:00:43,560
And these comparatives give our conditionals, like if and else statements, a lot more flexibility.
9
00:00:43,590 --> 00:00:47,750
Now some of you might have seen another type of equality comparative.
10
00:00:47,880 --> 00:00:54,350
So instead of using a three equal sign sometimes you see people using two equal signs.
11
00:00:54,350 --> 00:00:57,230
Now there's a big difference however between the two of these.
12
00:00:57,240 --> 00:01:04,590
So let's say we have a variable a and it's equal to 1 and then we have a variable b that's equal to
13
00:01:04,860 --> 00:01:06,690
the string 1.
14
00:01:06,690 --> 00:01:12,140
So this is 1 as a piece of text essentially, and they have different data types,
15
00:01:12,210 --> 00:01:20,430
because if we say type of a we get number and type of b we get string.
16
00:01:20,580 --> 00:01:30,540
So at this point if we check to see if a triple equals b, then if it's true we will get console.log
17
00:01:30,570 --> 00:01:31,570
“yes”
18
00:01:31,780 --> 00:01:35,670
and if it's false then we will get console.log “no”.
19
00:01:35,670 --> 00:01:43,500
So if I go ahead and hit enter right now then you can see that we get no, a does not triple equal b.
20
00:01:43,890 --> 00:01:53,790
But, however, if I was to modify this and change it to if a is a double equal to b and I hit run, then
21
00:01:53,790 --> 00:01:54,430
you can see we get
22
00:01:54,450 --> 00:01:55,040
yes
23
00:01:55,050 --> 00:01:56,280
in this case.
24
00:01:56,340 --> 00:02:02,580
So the important difference between three equal signs and two equal signs is that, even though they both
25
00:02:02,580 --> 00:02:05,590
check for equality, with three equal signs
26
00:02:05,610 --> 00:02:11,400
it’s also checking to see that the data types are matching, whereas with two equal signs it doesn't care
27
00:02:11,400 --> 00:02:12,770
about the data types.
28
00:02:12,780 --> 00:02:18,880
So let's head back to our love calculator and maybe one more thing that we could ask of it.
29
00:02:19,050 --> 00:02:24,450
What if we could separate our love score ranges a little bit more finely?
30
00:02:24,540 --> 00:02:31,110
So, for example, if we could have a different message for people who got between 1 and 30, then people
31
00:02:31,110 --> 00:02:38,300
who got between 30 and 70, and those who were ultra lucky and got between 70 and 100.
32
00:02:38,310 --> 00:02:40,310
How would we be able to do that?
33
00:02:40,500 --> 00:02:46,770
Well, we would have to learn how to combine different comparatives, and we'll tackle that in the next
34
00:02:46,770 --> 00:02:47,270
lesson.
35
00:02:47,340 --> 00:02:48,870
So that's all for me for today.
36
00:02:48,930 --> 00:02:50,910
And I will see you on the next lesson.
3652
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.