Interactive online courses HTML Academy
2026-03-09 14:09 Diff

Work on the program is in full swing and the Muffin asks us to make several changes to the logic of decision-making:

  • The project can be started if there are enough developers and if they have the knowledge of the necessary technology.
  • The project cannot be started if one of the developers is on vacation or is on sick leave.

We already know how to implement the first part of the logic, the one that contains and, using nested conditions. But what about the second part: the one that includes or? We can combine conditions inside if using logical operators: && and ||. For example:

var conditionOne = true; var conditionTwo = true; var conditionThree = false; var conditionFour = true; if (conditionOne && conditionTwo) { // code will be executed } if (conditionThree || conditionFour) { // code will also be executed }

The && operator or “logical AND” returns true only if both conditions, to the left and right of it, return true.

The operator || or “logical OR” returns true if any from the conditions to the left or to the right of it return true.

Now it is clear how to program the second part of the logic: let’s combine the conditions “employees on vacation” and “employees on sick leave” using “logical OR”.

We can also program the first part of the logic without nested if: let’s combine the conditions “there are enough developers” and “technology is mastered” using the “logical AND”. We decided not to nest the conditions as this could make the code complicated and confusing. If the nesting is large, then it becomes difficult to understand why this or that action is being performed.