Conditionals Recap

In this chapter, we learned how our program can decide what to do using conditions. We found that:

  • The if statement executes the following block of code if its condition is true.
  • An else if statement can follow an if statement, with an additional condition that executes the block of code of the else if statement if true.
  • An else statement can follow an if or else if statement. The block of code of the else statement executes if all previous conditions are false.
  • After the first true condition, the corresponding block of code is executed and the rest of the conditional chain is skipped.
  • Comparisons are made using the following operators: === - Equal to, !== - Not equal to, > - Greater than, >= - Greater than or equal to, < - Less than, <= - Less than or equal to.
  • We indent the block of code following a { for easier readability in the code.
  • There are two boolean values: true and false.
  • Using logical operators && (and), || (or), we can combine multiple conditions.
  • Using the ! (negation) operator, we can invert a condition from true to false or from false to true.
  • Nested conditions are those within the block of code of another condition.

Congratulations on completing the second lesson of JavaScript! In the next lesson, we will dive into the world of arrays and explore their amazing capabilities in programming. Get ready for an adventure full of efficient data storage and manipulation!

Instructions

When you are ready, proceed to the next lesson!

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

9/9

Conditionals Recap | Start Coder