02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School

Nested if conditions

Although we didn't dig to deep into the ways to work with if statements we are ready to take it up one more level so we can create our application.

Video Transcript

00:00Okay, and now we could go inside of our else statement
00:02and start working our else out.
00:04Now, we still don't know which one is true.
00:06We are now in a date that might be this one or that one.
00:09So we wanna test out that 415 one.
00:11And the way we do it is the exact same way
00:14as we created this if statement externally,
00:17we could create an if statement inside of our else area.
00:20What that would mean is that this if statement
00:23would only come to fruition,
00:25would only be called if we are in the else area.
00:29Right?
00:31So now that we are in the else area
00:32and we know that our date must be earlier than 415
00:35because we established that right here,
00:38it's time for us to find out if now is actually not earlier
00:42is greater than the late date,
00:44but if it's greater than the early date,
00:50what would that tell me if we know that we're
00:53if we know that we're in the early date?
00:56Well, basically it means that we're after the early date,
00:59but we're before the late date.
01:01That means we wanna have the center one not get dimmed out.
01:04So we wanna not dim out the center one,
01:06but instead of that, we wanna dim out the late date.
01:09Now, technically just because,
01:12just because we're already running in the date
01:14and currently the date is three,
01:19the 11th or 11th of the 4th of the 4th.
01:21So we're in the 11th of April,
01:23because we're in the 11th of April,
01:24it's actually gonna work.
01:25We don't have to do extra tests.
01:26Now we could see that our on time price is working.
01:29So we wanna test out our else statement as well
01:32on our else statement
01:35that was inside of the bigger else statement.
01:37We know that actually we wanna do the actual first one,
01:41because now we know that we're the early arrivals.
01:43So to do that,
01:44I just wanna make sure that my mid date is transparent
01:47and our last date is transparent as well.
01:50Now to test it out,
01:51all I'll do here is make sure
01:52that this if statement comes back false.
01:54So I'll type your false and end.
01:58Now the logic of false and end
02:00the logic of true or is basically,
02:04it works this way if statements,
02:06if I'm gonna say or I'm basically saying
02:08if this is true or that is true.
02:10If I say that this is true already,
02:12there doesn't really matter what happens afterwards.
02:15If I'm saying end,
02:16I'm basically saying this must be true
02:18and that must be true.
02:19By saying false and that must be true,
02:21I'm basically saying,
02:23I'm basically saying no matter what this can't come true.
02:26So if I run this one more time,
02:27we're gonna see that our application
02:28now is showing the early bird,
02:30which is exactly what we hoped it would do.
02:32We could comment this out
02:33and now we can see that our elements
02:35are working fantastically
02:38and we've just added our first component
02:40in our final project.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!