30 Days Of JavaScript

Day 7: Consolidation 1

Lesson 3: Logic

if

Logic, also known as conditionals, allows us to control which parts of our code get executed in which situations. The most basic form is the if statement.

We use boolean operators such as === or <= to determine if a condition is true or false and execute the relevant code.

AND

We can check multiple statements with the 'AND' operator &&

In an 'AND' check each condition being checked much be true for the overall condition to be considered true.

OR

If we want to execute code based on if one, or more, of any set of conditions are true, then we use the OR operator ||

If Else

To save us having to code for each version of a set of conditions, we can simply code an if and pair it with an else to catch the inverse of that check.

If, Else if, Else

If we do want to check some intermediate levels then we can use else if statements to catch those.

Outline

Go Pro?

If you upgraded to pro, sign in here

  • About
  • Blog
  • Privacy
Looking to email me? You can get me on my first name at allthecode.co