SwizzleDude SwizzleDude - 3 months ago 17
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 }


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