We have some more options for conditions, and one of them is called a territory operator, and this
is actually one of my personal favorites, that it allows you to really shorten that condition into
one statement.
So we've got an example here of how it works.
Got our condition, questionmark.
And then if that condition is true, we get value one being returned.
And if the condition is false, then we're going to get value to being returned.
In the example, we're looking at declaring a variable called status and we check to see if the value
of each is greater than or equal to 18.
And if it is, then status is going to be adult.
Otherwise status is going to be equal to minor.
So there is a challenge for this lesson and we're going to need to look at a value and check to see
if it's odd or even using the modulus to determine the output.
So checking to see a numeric value.
And if it's odd or even and I'll give you a quick sneak peek at the script and then show you the solution
so you can pause the video, try the code out.
All right.
Get your editors open and let's try this code out.
And we do modulus by another number.
We get a remainder returned.
So we know that 12 modulus two has no remainder odd number two or modulus to we do get a remainder.
So we're always going to get either a zero and one and going back.
We remember that these also can be used as boolean values, have a number with the modulus and then
return back a response.
You can see that it gets turned back as yes.
And then if we update the values to be 12 instead of 13, you're going to see that we're not going to
get this output being shown because this is no longer true.
So we can have a value and this can be any number that we want as a starting point.
And then we're going to do our territory operator.
We're going to include our condition and we can just call this status doing the rounded brackets in
order to include our calculation.
So we're taking the value and we're checking to see if there is a remainder in the value.
Otherwise if there's no remainder.
So we're going to get a boolean value or equivalent to a boolean value of false.
So that means that it is even.
So that means, though, no remainder and we can output those values so we can output the value into
the console.
Three is odd.
We can also try other numbers as well.
We get to is even let's try a really long number and this one is even as well.
Obviously, we also have an option to add in multiple conditions into conditional statements.
And that's coming up next.