Answer the question
In order to leave comments, you need to log in
How to make multiple conditions in an if and have them all run?
There is a condition like this:
if(function1 && function2){
// если обе возвращают true что то делаем.
}
Answer the question
In order to leave comments, you need to log in
Everyone seems to have forgotten that there are two options for "AND", as well as for "OR".
The first option is "&" : both the left and right parts will be checked, regardless of what the left part returns.
The second option is "&&" : the right side will only be checked if the left side returns true.
Therefore, in your version, if you want the check to be performed in any case both on the left and on the right, then
if(function1 & function2){
// если обе возвращают true что то делаем.
}
The most logical thing is to take
functionality to be executed in both, regardless of the resultfrom these functions. You are doing so-so side effects, because of which you will suffer later.
I did not understand the essence of your question) Try instead of "&&" - (and) use "||" - (or).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question