UberPooner Posted November 18, 2008 Share Posted November 18, 2008 Hi, is there a way to combine two if statements, like if they both had the same output.originalif(sho=="biz"){discount=1;}if(sho=="org"){discount=1;}Would it be something like this:if(sho=="biz"or"org"){discount=1;}tried it and didn't work, what should I do? Link to comment Share on other sites More sharing options...
Synook Posted November 18, 2008 Share Posted November 18, 2008 if(sho == "biz" || sho == "org") { discount=1;} Link to comment Share on other sites More sharing options...
inktherapy Posted November 18, 2008 Share Posted November 18, 2008 That is the logical "OR" operator and it returns a value of true if one or both of the operands is true. Link to comment Share on other sites More sharing options...
tyweiss Posted November 19, 2008 Share Posted November 19, 2008 also the "AND" operator is && if you need both conditions to be true for something to happen if you didn't know...hope that adds to your js knowledge ...if you already knew that then don't mind this reply....just trying to be helpful Link to comment Share on other sites More sharing options...
Synook Posted November 20, 2008 Share Posted November 20, 2008 You can make any type of logical operator with just and, or, and not (!condition). E.g., for XOR (exclusive or), you can do or and not and. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.