1
00:00:00,120 --> 00:00:05,610
We have some more options for conditions, and one of them is called a territory operator, and this

2
00:00:05,610 --> 00:00:11,130
is actually one of my personal favorites, that it allows you to really shorten that condition into

3
00:00:11,130 --> 00:00:12,150
one statement.

4
00:00:12,330 --> 00:00:14,540
So we've got an example here of how it works.

5
00:00:14,550 --> 00:00:16,500
Got our condition, questionmark.

6
00:00:16,500 --> 00:00:20,580
And then if that condition is true, we get value one being returned.

7
00:00:20,730 --> 00:00:25,830
And if the condition is false, then we're going to get value to being returned.

8
00:00:25,830 --> 00:00:31,110
In the example, we're looking at declaring a variable called status and we check to see if the value

9
00:00:31,110 --> 00:00:34,470
of each is greater than or equal to 18.

10
00:00:34,620 --> 00:00:38,040
And if it is, then status is going to be adult.

11
00:00:38,340 --> 00:00:41,260
Otherwise status is going to be equal to minor.

12
00:00:41,280 --> 00:00:47,220
So there is a challenge for this lesson and we're going to need to look at a value and check to see

13
00:00:47,220 --> 00:00:50,930
if it's odd or even using the modulus to determine the output.

14
00:00:51,150 --> 00:00:53,160
So checking to see a numeric value.

15
00:00:53,160 --> 00:00:58,860
And if it's odd or even and I'll give you a quick sneak peek at the script and then show you the solution

16
00:00:59,400 --> 00:01:02,090
so you can pause the video, try the code out.

17
00:01:02,100 --> 00:01:02,370
All right.

18
00:01:02,370 --> 00:01:05,220
Get your editors open and let's try this code out.

19
00:01:05,220 --> 00:01:07,980
And we do modulus by another number.

20
00:01:08,190 --> 00:01:09,870
We get a remainder returned.

21
00:01:10,260 --> 00:01:17,700
So we know that 12 modulus two has no remainder odd number two or modulus to we do get a remainder.

22
00:01:17,860 --> 00:01:21,510
So we're always going to get either a zero and one and going back.

23
00:01:21,510 --> 00:01:28,350
We remember that these also can be used as boolean values, have a number with the modulus and then

24
00:01:28,350 --> 00:01:29,910
return back a response.

25
00:01:30,090 --> 00:01:32,970
You can see that it gets turned back as yes.

26
00:01:33,120 --> 00:01:39,660
And then if we update the values to be 12 instead of 13, you're going to see that we're not going to

27
00:01:39,660 --> 00:01:43,410
get this output being shown because this is no longer true.

28
00:01:43,710 --> 00:01:48,030
So we can have a value and this can be any number that we want as a starting point.

29
00:01:48,360 --> 00:01:50,460
And then we're going to do our territory operator.

30
00:01:50,460 --> 00:01:56,160
We're going to include our condition and we can just call this status doing the rounded brackets in

31
00:01:56,160 --> 00:01:58,230
order to include our calculation.

32
00:01:58,440 --> 00:02:03,590
So we're taking the value and we're checking to see if there is a remainder in the value.

33
00:02:03,600 --> 00:02:06,720
Otherwise if there's no remainder.

34
00:02:06,720 --> 00:02:11,490
So we're going to get a boolean value or equivalent to a boolean value of false.

35
00:02:11,700 --> 00:02:13,390
So that means that it is even.

36
00:02:13,410 --> 00:02:19,050
So that means, though, no remainder and we can output those values so we can output the value into

37
00:02:19,050 --> 00:02:19,730
the console.

38
00:02:19,740 --> 00:02:21,000
Three is odd.

39
00:02:21,190 --> 00:02:23,490
We can also try other numbers as well.

40
00:02:23,790 --> 00:02:28,170
We get to is even let's try a really long number and this one is even as well.

41
00:02:28,170 --> 00:02:32,910
Obviously, we also have an option to add in multiple conditions into conditional statements.

42
00:02:33,030 --> 00:02:34,290
And that's coming up next.
