Basic Other Operators from Digital Marketing Company in Kolkata
This can be anything this can be a function this can be something that it just has to basically evaluate to TRUE or FALSE. So here we can kind of put some math in here. If bank balance is greater than or equal the cost of the item plus tax rate and we know we won't have to convert this because it's already a number it's not a string but let's try to run it right so it doesn't execute this block of code because now the value is too high. The bank balance is no lower than as suggested by a digital marketing company in Kolkata the total amount in your bank account. What if our balance was just to do a sanity check just to make sure it runs. There we go.
So if we have more money we could purchase it. Otherwise, we can't. What if we wanted to do the opposite in other words what if we wanted to check that the balance was less than the cost of the flight. Maybe our logic is inverted we want to a log. You cannot purchase this item and just kind of do some other kind of code to prevent it from happening for example. So pop up something in the browser saying Oops you don't have enough money for this. Right.
So for example instead of Consolo, we can do an alert just for a bit of you know change of pace. And in that case. Well with a digital marketing company in Kolkata you might expect it just kind of is the opposite. So let's get rid of the tax for now. So if the bank balance is less than the cost of the item we will throw up an alert and notice that the little sign has switched direction. Now the alligator is on the left side and it's eating the cost of the item right. So let's see here. It doesn't run because it's there.
They're both exactly equal. Right but if bank balance was slightly less run it's oh no we can't purchase this item and we could do like some kind of prevent default behavior from firing because the user doesn't have enough money in their bank account or something like that. All right so that definitely works. What if we said if it's less than or equal. So maybe the user has some kind of preventative measures so that they don't spend every single penny in their bank account right here or checking if bank balance is less than or equal to the cost of the item. Then we'll throw up the alert.
Hey, you can't purchase this item. Let's check it out digital marketing company in Kolkata there. Our alert has fired you cannot purchase this item. OK. That's too bad especially if we start to add in tax rates so plus tax and we don't need to check equal we just check less than right so users said you know what. It's OK if I spent every penny. I just want to make sure I have enough money in my bank account. Run. OK. So we can't purchase that item. That's too bad. Right.
So less than equal to both commonly used all over the place in your statements. Now a couple of other operators we can talk about that might get rid of some code here to get rid of this line. It's something we should check if two things are not equal and this might be a little bit confusing to wrap your head around if you're the kind of new to programming so let's do a couple of examples here. I'm going to make space down below.
So let's say we want to compare is bank balance different from the cost of light. In other words are they different. If so I want to return true right because in our statement the block only executes if it evaluates to true. And what I mean by that is you know let's make balance and bank account slightly different. So we'll make bank count. And if you cancel that log Let's compare these two things or say bank account balance. Is it equal to the cost of the item? And we know of course that this will evaluate to be false.
So if we just check this which we've done in our statement we won't be able to execute the block of code but on the other hand, if we want to check if they're different right. So if we want to check that bank balance is not the same as the cost of the item. We're going to want to do one of these guys. Right, so exclamation equals. Let's run this. This evaluates digital marketing company in Kolkata to true. So a little bit counterintuitive at first if you're still kind of new to coding but this is us saying OK, this is not equal to this. This will return as true right. So it might kind of be the opposite of what you expect but it's just a way of manipulating the data rate so we're checking.
This is not equal to this return true. Otherwise, it would have been false or if we're just straight up checking. Of course, we know this is false. And definitely in my experience, it takes a little bit of thinking to get your mind around to wrap your head around if you're still kind of new. How can this evaluate to true? And really it's just comparing two things and getting a result. This is a way of checking things are not equal if you think of it in that way.
So triple equals checks that they are the same and equal checks that they are not the same. And by the way, you can do it this way as well not equal. This is basically in the same lines as doing one of these double equal sign. So it's not quite as exact. So if we do one of these. So this works. But again I would caution you just always be more specific. Use the No more specific version. This you can do you know what your type conversion if you need to see if I can read this for example into a string. It's going to be able to compare them and it should return as is true right that they're not the same. But if I made this into: for example now it's false.
Now it's considering them to be the same. So definitely something to be aware of and you're going to want to use the triple version wherever you can. Here at a digital marketing company in Kolkata, it's doing it accurately here. These are not the same because this is a string. And of course, this is not a string. So just something to watch out for. And again be as specific as you can be.
Now then let's incorporate this into an IF statement. So if we want to keep with the theme of bank balance so if the bank account balance is not equal to the cost of the item plus tax then we can execute a block of code. So we want this to evaluate to true.
Otherwise, this block of code won't run right. So console log I am running pretty easy to tell if it's running or not but just kind of a good sanity check here. Let's clear it or run it. And hey it makes sense they're not equal. What if the tax was actually one it doesn't execute. Because these are now exactly equal you know bank accounts probably the simplest example but you can probably imagine other scenarios where this would come in handy right. Maybe some kind of timer app or something like that. There are all kinds of reasons you would want to compare numbers.