Jump to content

Recommended Posts

Posted

I'm not sure if you are using "&&" and "||" the way they are intended to be used in javascript. As far as I know, they are intended to be used as part of a conditional statement, like "if" or a "while" loop....

 

if (var1 10) for example.

 

If you are wanting to combine the two variables, for example, 10+20, or "cat" + "dog" you'll need to use "+". Combining booleans will give you their value (false = 0, true = 1).

 

---

 

I will point out that:

-- if you try to use "20 && 10", the result will always be the last variable ("10")

-- if you use " "cat && "dog" " (you need "" around the text, because they are strings) you'll get the last variable ("dog")

-- if you use "true && false", you'll get false if any one of the variables are false (order doesn't matter) and true otherwise.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...