+ 1
How can I put 3 variables into the if-condition?
If I want the condition to be more than 25, but less than 100. I have tried: if (25 > x < 100) {...}; but it didn't work.
2 Answers
0
if (x > 25 && x < 100)
{...}
- 1
Use the "&&" logical operator.
if (x > 25 && x < 100)
{
//code
}
There is no limit to how many of these operators you can have in parameters.
Also, the logical operator "||" means "or". So you could do:
if (x < 25 || x > 100)
{
//code
}