Hello, in this JavaScript video, I am going to show you the conditional operator. As you can guess it's an operator that allows you to check some sort of condition, I'm going to be honest, I'm not a big fan of the conditional operator, I generally don't like using it simply because I don't like the syntax, the format of it, I would rather use a conditional statements such as an if statement, but I think it is important to show you the, you know, different programming features, even if you know, I particularly don't like them so you can choose which one you want to use, but I'll give you my opinion as well. So okay, what we're going to do is create a couple of variables var one, one is a value of nine, two phones the value of 100. Doesn't matter what they are, and we're going to create another variable.
I'm going to call it though, equals and this is going to be our conditional operator. So what we do is we put brackets then we put some sort of check, you know, the sort of checks that we done before in the previous video that allow us to actually, you know, check if two variables same for the equal operator, the not equal to the greater than soulmate, the comparison operator. So you put one of them in here doesn't really matter which one you choose. I'm simply going to say num one is equal to num two. So does num one equal num two and we know it doesn't. And then we do it put a question mark.
And now you put a value so if I put that Yay. And then I'll put the colon semi colon this up just reduce the size this. So what this is saying, If num one equals num two, then assign this value doesn't have to be a string, it could be an object, it could be a number doesn't really matter, sign this value to result. Otherwise, if this condition fails assign name. So if we do console dot log result of that, refresh, we get an A cuz nine does not equal 100. Or changes to 100.
However, and reload, we get yay because it doesn't click and that's it. You know, I could put less than, and if I were to put law to, if I were to put that 100 is not less than 100 a day or the same, therefore it assigned nay. Again, you can put any comparison operator any combination of them and if the result What's in the brackets is true, then it will assign its value. Otherwise, he assigns this value. So that's it for the conditional operator. If you have any questions, feel free to pop me a message.
The GitHub link will be available so you can check out the source code as well, and I look forward to seeing you in the next video.