Home > Software design >  javascript with two conditions that can't be met at the same time
javascript with two conditions that can't be met at the same time

Time:09-03

I'm trying to write an if statement that logs true if z is less than 100, or if z is greater than 200. I understand how to write with two conditions that work at the same time with a given number but how would I write it where the correct answers don't overlap? Is there some sort of 'or' statement I could use?

CodePudding user response:

When at least one condition has to be met for the if block to run use logical OR (||):

if (z < 100 || z > 200){
 true;
}
  • Related