Sometimes, we want to test if a variable does not equal either of two values with JavaScript.
In this article, we’ll look at how to test if a variable does not equal either of two values with JavaScript.
How to test if a variable does not equal either of two values with JavaScript?
To test if a variable does not equal either of two values with JavaScript, we use boolean operators.
For instance, we write
if (test !== "A" && test !== "B") {
//...
}
to check if test
isn’t 'A'
and also isn’t 'B'
.
Conclusion
To test if a variable does not equal either of two values with JavaScript, we use boolean operators.