HTML Academy
Logical operators: &&, ||
Conditions13/17
Back to the list of tasks
  • 1. Simple fork
  • 2. Let’s use an alternative
  • 3. Simple comparisons
  • 4. Comparisons permitting equality
  • 5. Equality, inequality
  • 6. Strict string comparison
  • 7. Strict number comparison
  • 8. Condition-based actions
  • 9. If the condition is not fulfilled
  • 10. Values ​​as a condition
  • 11. Nested conditions
  • 12. Logical operators: &&, ||
  • 13. Logic traps
  • 14. Logical negation
  • 15. Let’s combine logical operators
  • 16. Summary of “Conditions”
  • 17. Second program: “How long to take a walk for?”
Logical negation
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Logic traps

An error slipped into the current program. I’m just quoting what the boss said in his letter:

It’s kind of, meow, difficult.

First, he checks one and says that you can start.

And then he starts to check either this or that, and says that you should wait.

And I see two messages: first saying that you can, and then right away saying that you cannot. And I do not know what to do.

Let him just say when you can start, and when you cannot.

It’s a pity that you had to deal with the tasks “analyzing boss requirements” and “fixing bugs using mind-reading” so early. But nothing can be done about it. Let’s figure out what the error is and what the boss wants.

We can see from the letter that under certain conditions the program logs two messages at once. For the error to be detected, it must first be reproduced. So let’s change the values ​​of the input data.

Comments

  • script.js
JavaScript
var enoughDevelopers = false; var techAvailable = false; var onVacation = false; var onSickLeave = false; if (enoughDevelopers && techAvailable) { console.log('You can start the project'); } if (onVacation || onSickLeave) { console.log('It is better to wait'); }

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

Console

The code has changed, click “Run” or turn autorun on.

Result

Goalscompleted

In turn, change the values ​​of the variables.

  1. Indicate that there are enough developers.
  2. Indicate that the developers mastered the technology.
  3. Indicate that one of the developers is on vacation.

Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2025

VISAMastercard

Log in

or

Forgot your password?

Sign up

Sign up

or
Log in

Restore access

Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

Forgot to connect your email to the profile? Email us and we’ll help.