1
00:00:00,390 --> 00:00:08,340
So now we can do the rest of the condition where we can pass the value in and either get a response

2
00:00:08,340 --> 00:00:11,370
for the function, so let's set up the function.

3
00:00:11,380 --> 00:00:20,880
So setting up a separate function, check the time of day, and then this is going to take one parameter.

4
00:00:21,090 --> 00:00:22,160
So it's going to be a number.

5
00:00:22,500 --> 00:00:29,820
So we want to make sure that whatever value is being passed in here, that this value will return back

6
00:00:29,820 --> 00:00:31,500
a message for the user.

7
00:00:31,710 --> 00:00:33,960
And we're going to use the switch statement for this.

8
00:00:34,620 --> 00:00:35,760
So it's posehn.

9
00:00:36,120 --> 00:00:39,780
Whatever adds is into the check time of day.

10
00:00:40,260 --> 00:00:44,910
And then over here, we want to return back of value for the user.

11
00:00:45,090 --> 00:00:47,300
So let's use the switch statement.

12
00:00:47,790 --> 00:00:52,510
So whatever number is passed in here and and we know that it is a number.

13
00:00:53,070 --> 00:00:57,510
So using switch number and now we can check the case.

14
00:00:57,960 --> 00:01:05,280
And if the NUM is less than 12, then we're going to have the case of true.

15
00:01:05,790 --> 00:01:07,800
Which we can return.

16
00:01:08,400 --> 00:01:09,790
Good morning.

17
00:01:10,140 --> 00:01:11,670
And don't forget the break.

18
00:01:11,850 --> 00:01:15,300
And then the other case is going to be false afternoon.

19
00:01:15,660 --> 00:01:17,720
And we can also have a default case.

20
00:01:17,940 --> 00:01:24,400
So we're checking that we're passing in a value if the value of NUM is less than 12.

21
00:01:24,450 --> 00:01:28,040
So this comes back true that we're going to say good morning, return back.

22
00:01:28,050 --> 00:01:28,650
Good morning.

23
00:01:28,800 --> 00:01:31,290
And we'll output that message on the page.

24
00:01:31,620 --> 00:01:35,220
So but we added in and update.

25
00:01:35,640 --> 00:01:39,280
We're just going to add in a new div and what time is it?

26
00:01:39,300 --> 00:01:40,860
And so saying what time is it?

27
00:01:41,530 --> 00:01:44,100
Let's take a selection of that element.

28
00:01:44,130 --> 00:01:53,820
So message and then documents query selector select element with a class of message and let's update

29
00:01:53,820 --> 00:01:59,400
the entire text of message and update the text content of whatever gets returned back and mess.

30
00:01:59,670 --> 00:02:05,160
And we could even make this shorter by whatever gets returned back is going to be what we're going to

31
00:02:05,160 --> 00:02:07,320
place within the message area.

32
00:02:07,530 --> 00:02:09,690
And now we are ready to try that.

33
00:02:09,700 --> 00:02:15,390
So let's enter in a number that says good morning and if the number is larger, it's just going to say

34
00:02:15,390 --> 00:02:16,290
good afternoon.

35
00:02:16,800 --> 00:02:21,180
And we should also check to see if that number is too large.

36
00:02:21,330 --> 00:02:29,760
So essentially, the way that the switch works is it checks to see what the expression evaluates to.

37
00:02:30,030 --> 00:02:33,100
And then you have the various case, possible results.

38
00:02:33,750 --> 00:02:41,220
Let's do another quick one, WorldWar, update the message value to whatever the time of whatever the

39
00:02:41,220 --> 00:02:42,690
day is currently right now.

40
00:02:43,260 --> 00:02:49,170
So right now, I'm recording this on a Thursday, so let's output Thursday and I'll just call it output

41
00:02:49,170 --> 00:02:51,220
today and then we'll run this function.

42
00:02:51,630 --> 00:02:56,360
So this function will take in whatever the current date is.

43
00:02:56,880 --> 00:03:04,770
So whatever the value of today is, so new date object and we're going to use the get B method.

44
00:03:05,040 --> 00:03:12,120
So it's going to return the day of the week and we'll consider log out whatever the day of the week

45
00:03:12,120 --> 00:03:12,360
is.

46
00:03:12,520 --> 00:03:15,900
So it's going to be a numeric value from zero to six.

47
00:03:16,500 --> 00:03:21,840
And then let's run this whenever the page loads through a run that.

48
00:03:23,770 --> 00:03:29,290
So Stewart gets out, put into the console, so it's coming back as four, so four is equal to Thursday,

49
00:03:29,560 --> 00:03:32,400
starting out on Sunday, which is zero.

50
00:03:32,530 --> 00:03:34,580
So let's return back to the actual date.

51
00:03:35,260 --> 00:03:45,400
So let's use a switch statement and whatever the value of today is, and if the case is zero, then

52
00:03:45,550 --> 00:03:48,270
the day is going to be Sunday.

53
00:03:48,700 --> 00:03:53,350
So let's say at the end of the day, name unknown.

54
00:03:54,790 --> 00:03:57,220
So it's our default, which just going to set it to unknown.

55
00:03:57,490 --> 00:04:07,960
And if the case is zero, then we're going to set the name to equal to Sunday and then we'll break case

56
00:04:07,960 --> 00:04:10,230
one and same format.

57
00:04:10,450 --> 00:04:16,030
So if it's one, then this is going to be equal to Monday and then we break on that.

58
00:04:16,250 --> 00:04:19,090
And you always need to include the the break.

59
00:04:19,090 --> 00:04:24,850
If you don't include the break, then you're going to have an issue with it's going to just return back

60
00:04:24,850 --> 00:04:25,960
whatever values are.

61
00:04:25,960 --> 00:04:29,200
So I'll show you how it works without the break.

62
00:04:29,320 --> 00:04:31,930
And then I'll also show you how it works with the break.

63
00:04:32,530 --> 00:04:38,620
So it's going to automatically go to case number four, because that's what day it is, what day of

64
00:04:38,620 --> 00:04:39,280
the week it is.

65
00:04:39,640 --> 00:04:46,480
So if I've forgotten the break, so first of all, just make sure that we're getting the deal value

66
00:04:46,480 --> 00:04:46,990
out there.

67
00:04:46,990 --> 00:04:50,040
So five and then the last ones, six.

68
00:04:51,010 --> 00:04:55,630
So this will say Friday and this was a Saturday.

69
00:04:56,470 --> 00:05:01,300
So we're returning back the different value of the day.

70
00:05:02,380 --> 00:05:04,870
And I'll actually I'll update message.

71
00:05:06,430 --> 00:05:15,190
Tax content to equal and today is a whatever the day name is, so let's see what happens refreshed today

72
00:05:15,190 --> 00:05:19,780
as of Thursday and what happens if I forget the break after Thursday.

73
00:05:20,710 --> 00:05:27,340
So we refresh and it will say today is a Friday because it's going to move to the next available assignment

74
00:05:27,340 --> 00:05:27,810
value.

75
00:05:27,850 --> 00:05:31,350
So it's going to go through here and it's not going to have any break.

76
00:05:31,360 --> 00:05:36,730
So it's going to continue and it's going to say, OK, well, day name equals Thursday, but there's

77
00:05:36,730 --> 00:05:37,390
no break.

78
00:05:37,390 --> 00:05:44,530
So I'll reassign the value of the name and it will assign it to Friday because there's no break from

79
00:05:44,530 --> 00:05:44,910
the code.

80
00:05:45,370 --> 00:05:55,960
You can also sign using values so you can check to see on the switch so we can have another switch statement

81
00:05:56,200 --> 00:06:04,000
and this can take in the day name and it can check to see if it's the beginning of the week or the end

82
00:06:04,000 --> 00:06:04,480
of the week.

83
00:06:04,690 --> 00:06:16,240
So depending on what the value is, Siletz week status and I'll set that to unknown as well, and then

84
00:06:16,240 --> 00:06:18,280
we'll update the week status.

85
00:06:19,480 --> 00:06:20,770
So depending on the case.

86
00:06:20,890 --> 00:06:21,780
So case.

87
00:06:22,630 --> 00:06:32,380
So if the case is equal to, let's say, Thursday and we'll update week status and we can have multiple

88
00:06:32,710 --> 00:06:42,400
cases or the end of week, and then we'll just break your case and also I'll just use the case or the

89
00:06:42,400 --> 00:06:43,400
default value.

90
00:06:43,720 --> 00:06:44,950
So it's not the end of the week.

91
00:06:44,950 --> 00:06:46,340
That's going to be the beginning of the week.

92
00:06:46,780 --> 00:06:52,600
So default and it's going to default to week status beginning of the week or I'll just call it start

93
00:06:52,600 --> 00:07:00,040
a week, start of week and I'll update these to use the tactics, the template literals so it doesn't

94
00:07:00,040 --> 00:07:02,710
look as cluttered using the template.

95
00:07:02,980 --> 00:07:05,470
Today is a whatever the day of the week is.

96
00:07:05,620 --> 00:07:10,680
It's the whatever the week status is, and then use a tactic to close that off.

97
00:07:11,620 --> 00:07:12,890
So let's see what happens.

98
00:07:12,910 --> 00:07:16,150
So today is a Thursday, it's the end of the week.

99
00:07:16,480 --> 00:07:22,900
And then we also saw with the way that the brick works so we can remove those and that's not going to

100
00:07:22,900 --> 00:07:23,650
change anything.

101
00:07:23,680 --> 00:07:26,200
So today is a Thursday at the end of the week.

102
00:07:26,500 --> 00:07:30,870
If we remove out the Thursday as a case and only have it Friday.

103
00:07:31,120 --> 00:07:34,600
So it's a Thursday start of the week because we're just using the default.

104
00:07:34,990 --> 00:07:39,790
So let's say you can use the switch statements and customise the output messages to the users.
