Categories
JavaScript Answers

How to test if a variable does not equal either of two values with JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *