So now we can do the rest of the condition where we can pass the value in and either get a response
for the function, so let's set up the function.
So setting up a separate function, check the time of day, and then this is going to take one parameter.
So it's going to be a number.
So we want to make sure that whatever value is being passed in here, that this value will return back
a message for the user.
And we're going to use the switch statement for this.
So it's posehn.
Whatever adds is into the check time of day.
And then over here, we want to return back of value for the user.
So let's use the switch statement.
So whatever number is passed in here and and we know that it is a number.
So using switch number and now we can check the case.
And if the NUM is less than 12, then we're going to have the case of true.
Which we can return.
Good morning.
And don't forget the break.
And then the other case is going to be false afternoon.
And we can also have a default case.
So we're checking that we're passing in a value if the value of NUM is less than 12.
So this comes back true that we're going to say good morning, return back.
Good morning.
And we'll output that message on the page.
So but we added in and update.
We're just going to add in a new div and what time is it?
And so saying what time is it?
Let's take a selection of that element.
So message and then documents query selector select element with a class of message and let's update
the entire text of message and update the text content of whatever gets returned back and mess.
And we could even make this shorter by whatever gets returned back is going to be what we're going to
place within the message area.
And now we are ready to try that.
So let's enter in a number that says good morning and if the number is larger, it's just going to say
good afternoon.
And we should also check to see if that number is too large.
So essentially, the way that the switch works is it checks to see what the expression evaluates to.
And then you have the various case, possible results.
Let's do another quick one, WorldWar, update the message value to whatever the time of whatever the
day is currently right now.
So right now, I'm recording this on a Thursday, so let's output Thursday and I'll just call it output
today and then we'll run this function.
So this function will take in whatever the current date is.
So whatever the value of today is, so new date object and we're going to use the get B method.
So it's going to return the day of the week and we'll consider log out whatever the day of the week
is.
So it's going to be a numeric value from zero to six.
And then let's run this whenever the page loads through a run that.
So Stewart gets out, put into the console, so it's coming back as four, so four is equal to Thursday,
starting out on Sunday, which is zero.
So let's return back to the actual date.
So let's use a switch statement and whatever the value of today is, and if the case is zero, then
the day is going to be Sunday.
So let's say at the end of the day, name unknown.
So it's our default, which just going to set it to unknown.
And if the case is zero, then we're going to set the name to equal to Sunday and then we'll break case
one and same format.
So if it's one, then this is going to be equal to Monday and then we break on that.
And you always need to include the the break.
If you don't include the break, then you're going to have an issue with it's going to just return back
whatever values are.
So I'll show you how it works without the break.
And then I'll also show you how it works with the break.
So it's going to automatically go to case number four, because that's what day it is, what day of
the week it is.
So if I've forgotten the break, so first of all, just make sure that we're getting the deal value
out there.
So five and then the last ones, six.
So this will say Friday and this was a Saturday.
So we're returning back the different value of the day.
And I'll actually I'll update message.
Tax content to equal and today is a whatever the day name is, so let's see what happens refreshed today
as of Thursday and what happens if I forget the break after Thursday.
So we refresh and it will say today is a Friday because it's going to move to the next available assignment
value.
So it's going to go through here and it's not going to have any break.
So it's going to continue and it's going to say, OK, well, day name equals Thursday, but there's
no break.
So I'll reassign the value of the name and it will assign it to Friday because there's no break from
the code.
You can also sign using values so you can check to see on the switch so we can have another switch statement
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
of the week.
So depending on what the value is, Siletz week status and I'll set that to unknown as well, and then
we'll update the week status.
So depending on the case.
So case.
So if the case is equal to, let's say, Thursday and we'll update week status and we can have multiple
cases or the end of week, and then we'll just break your case and also I'll just use the case or the
default value.
So it's not the end of the week.
That's going to be the beginning of the week.
So default and it's going to default to week status beginning of the week or I'll just call it start
a week, start of week and I'll update these to use the tactics, the template literals so it doesn't
look as cluttered using the template.
Today is a whatever the day of the week is.
It's the whatever the week status is, and then use a tactic to close that off.
So let's see what happens.
So today is a Thursday, it's the end of the week.
And then we also saw with the way that the brick works so we can remove those and that's not going to
change anything.
So today is a Thursday at the end of the week.
If we remove out the Thursday as a case and only have it Friday.
So it's a Thursday start of the week because we're just using the default.
So let's say you can use the switch statements and customise the output messages to the users.