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

Overview

In this set of summaries on conditionals, we'll focus on the language 'switch' construct. Apparently the name of the construct, "switch," does scare away a lot of novice or beginner programmers. One can only attribute this "fear" to the choice of the English word used to name it. In other words, we use "if" and "else" in everyday English communication, so it's very intuitive.

The "switch" keyword reminds us of our parents nagging at us to turn off light switches when not in use, while we were kids! We are no longer kids (or at least that's what all of us want to believe,) so let's get on with it. The switch construct is here to stay, and if we want to be prolific programmers, we better know how to use it and how to use it well.

Another topic we intend to discuss in this set of summaries is the ternary operator, and this language construct scares away not only novice programmers, but experienced ones as well! To be frank it does look cryptic, since right from childhood, we are exposed only to unary and binary logical (while learning Math) and arithmetic operators. So the ternary operator does not appear natural, or intuitive. But as we'll soon discover, this operator has the potential to cut down on the lines of code one must write to express a 2-way decision making construct. Just keep this in the back of your mind: the ternary operator is a magic fairy that can produce the result of a 2-way choice in a jiffy. Only you need to invoke the fairy calmly and carefully, so as not to upset her!

So, we hope you're all set to dive head-first into the fascinating world of conditionals-2, with a slightly different approach and rephrasing of syntactical elements to achieve the same results as the if-else clauses. Let's start right away!

Video Transcript

00:00Fantastic work. Well you're halfway through and you've learned already some
00:04really really important concepts concepts from variables to operators to
00:09conditionals part one. Now in this topic we're talking about conditionals part
00:13two and again if you don't know everything until now then make sure you
00:16go to everythingaffiliate.com, take the exams, confirm that you do know the
00:19information. If you're not sure rewatch the videos, if you're still not sure go
00:24to our community, ask questions. If you're still not sure contact our
00:27support and ask us to give you some homework and we're always happy to do
00:30that. So we're assuming now that you already know conditionals part one and
00:34conditional part two is way easier. Most of the videos are really just about
00:38learning about one new thing, a new concept, a new way of asking if statements
00:43which is called switch and we're going to look at the switch syntax and it's
00:46really just about a different way of doing it. So one thing is don't be scared
00:51of it. It's really really if only a very more simplified if, a different way
00:56of asking conditions. Now there's a few tricks and a few differences between if
00:59and switches and we're going to look and break it down and look into it. We're
01:03going to even look at a sample where switches are just more useful than if
01:06cases. Now we're going to look at it, we're going to ask what things could if
01:09statements do, what switch could do, when should you use this, when should you
01:13use that and then we're going to cover lastly a really really cool thing
01:17that's not as well known and really if you know this then you're
01:21you're going to impress people in that level. A lot of developers don't know
01:24even about ternary operations. I hope I'm saying it out loud the right way. So
01:30we're going to look at a ternary operation and really those are the two
01:33main topics. We're going to cover switches very very easy. Half of a course
01:37you know you should pass this with flying colors hopefully and then
01:41ternary operation. Just make sure that you understand the syntax, make sure you
01:44understand the syntax and then the exams exams exams. It's really the key
01:48exams and exercises and challenging yourself and as always don't
01:52forget exams, community, support, you'll always find them at everythingaffiliate.com

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!