1
00:00:00,560 --> 00:00:06,110
This is challenge number three, we're building hello, greeter, so first we have to set a default

2
00:00:06,110 --> 00:00:11,900
time so you can set up a variable and set any time you want and then depending on the time, we're going

3
00:00:11,900 --> 00:00:13,170
to output a message.

4
00:00:13,340 --> 00:00:16,340
So, for example, in the morning we could put out good morning.

5
00:00:16,520 --> 00:00:21,470
So depending on what the time reads, we want to output a different message in the console and then

6
00:00:21,470 --> 00:00:27,140
we can manually adjust the variable value of the time and have a bunch of different messages being output.

7
00:00:27,380 --> 00:00:32,810
So here's an example of the code so you can pause the video work through this example and I'll show

8
00:00:32,810 --> 00:00:34,610
you the solution coming up.

9
00:00:35,020 --> 00:00:40,260
So first of all, we need to set a time so we can set this time to be whatever we want.

10
00:00:40,610 --> 00:00:45,920
So let's start out with 9:00 a.m. We're going to do a 24 hour clock in this case, and then we're going

11
00:00:45,920 --> 00:00:52,100
to declare variable output so that we can use that in order to output that information into the console

12
00:00:52,400 --> 00:00:53,390
and console.

13
00:00:53,390 --> 00:00:56,730
Log that out and we're going to put the statement in the middle there.

14
00:00:57,050 --> 00:01:00,680
So for now, when we declare, we see that it's just undefined.

15
00:01:00,890 --> 00:01:02,650
So let's add in our condition.

16
00:01:03,050 --> 00:01:05,930
So checking to see the value of my time.

17
00:01:06,060 --> 00:01:13,850
And if it's under 11:00 a.m., then we can set a value for output to be equal to good morning.

18
00:01:13,850 --> 00:01:17,750
And else we can say that I'm sleeping.

19
00:01:17,960 --> 00:01:19,090
So we get good morning.

20
00:01:19,100 --> 00:01:23,830
And of course, obviously, if we adjust this, then we're going to get a different output.

21
00:01:24,110 --> 00:01:30,530
So let's add in some additional else statements are going to use or else if in order to add those in

22
00:01:30,770 --> 00:01:34,990
so we can do another one or else if and have another condition in there.

23
00:01:35,030 --> 00:01:42,620
And this one is going to use the logical operator because we're going to be checking the Y time and

24
00:01:42,620 --> 00:01:46,790
we're checking to see if it's greater than or equal to 11.

25
00:01:46,800 --> 00:01:53,840
And we also want to make sure that my time is less than or equal to whatever whatever the next interval

26
00:01:53,840 --> 00:01:54,170
is.

27
00:01:54,380 --> 00:02:01,740
So this is going to be 17 where we're going to output a value for output of good afternoon.

28
00:02:02,150 --> 00:02:08,430
And in this case, we want to use that and to make sure that both of these are coming back as true.

29
00:02:09,050 --> 00:02:10,760
So save and try that.

30
00:02:10,790 --> 00:02:12,590
So first it comes back as sleeping.

31
00:02:13,010 --> 00:02:17,900
So let's adjust that so that we land our time to 3:00 p.m. and we see that we get.

32
00:02:17,900 --> 00:02:18,710
Good afternoon.

33
00:02:20,340 --> 00:02:26,400
Let's do a few more, a few more in so another EL statement, I just did a quick clean up their.

34
00:02:27,520 --> 00:02:34,450
So next interval is we're checking to see if it's larger than 17, so it is going to make sure that

35
00:02:34,450 --> 00:02:36,000
we are accounting for everything.

36
00:02:36,010 --> 00:02:39,010
So this is less than or equal to 17.

37
00:02:39,190 --> 00:02:43,490
So that's why this one isn't equal to 17, because there would be no point.

38
00:02:43,510 --> 00:02:47,720
And of course, this one, if it was 17, that one would already equate to being true.

39
00:02:47,950 --> 00:02:50,260
So that's why we're leaving out the other equal sign, their.

40
00:02:51,240 --> 00:02:57,660
And then we're also checking to see if my time is less than twenty three and if it is, then we're going

41
00:02:57,660 --> 00:02:58,230
to output.

42
00:02:58,230 --> 00:02:59,070
Good evening.

43
00:02:59,310 --> 00:03:00,280
Let's try that again.

44
00:03:00,440 --> 00:03:03,810
So good afternoon and let's try 22 o'clock.

45
00:03:03,960 --> 00:03:05,280
And that's good evening.

46
00:03:05,310 --> 00:03:10,770
So you can play around with this and add in as many options as you can, always using the conditions

47
00:03:10,770 --> 00:03:15,990
to make sure that you're getting the right interval between the times so that you can output the correct

48
00:03:15,990 --> 00:03:18,630
message depending on whatever the time value is.

49
00:03:18,780 --> 00:03:23,700
Next, I'm going to show you another way to do this and an even easier way using the switch statement.

50
00:03:23,890 --> 00:03:24,780
That's coming next.
