HTML Academy
Summary of “Conditions”
Conditions17/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?”
List of tasks
  • Sign up
  • Log in

Register to take up challenges

Registration will only take a minute and let you save your study progress. You can register with your email and password or login via social networks.

or
Log in and continue
  • script.js
JavaScript
var temperature = 20; var isRaining = true; var minutes = 0; /* Meow! The length of the walk depends on several conditions. If it’s raining, I do not go for a walk. In this case, the duration of the walk equals 0. But if there is no rain, it all depends on the temperature outside: First, if the temperature ranges from 10°C (inclusive) to 15°C (not including this value), I walk for 30 minutes. Second, if the temperature ranges from 15°C (inclusive) to 25°C (not including this value), I walk for 40 minutes. Third, if the temperature ranges from 25°C (inclusive) to 35°C (inclusive), I walk for 20 minutes. In other cases, I do not go out anywhere: it’s either very cold or very hot. The result of the program is the time of the walk. It must be written into the variable minutes. */

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

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.