SwizzleDude SwizzleDude - 1 year ago 131
Javascript Question

Conditional OR statements

How do I implement a test, if a variable equals another, OR another?
I want it to compare the variable "Potato" with the strings "sweet" and "elephant".
Like this here (does not work):

if (Potato === "sweet" or "elephant") { //do stuff }

Answer Source

Here's what you need to do for working with an "or" condition.

if (Potato === "sweet" || Potato === "elephant") { 
/*your code here*/ 


For further reference to JavaScript Comparison and Logical Operators, check this out - http://www.w3schools.com/js/js_comparisons.asp

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download