What is a conditional statement

A conditional statement executes a code if a condition is met or something else if that condition is not met.

If you get a 10 at school then I will buy for you a new bike, otherwise I will give you just a cookie!

Cause 1 – get a 10 at school
Effect 1 – get a new bike

Cause 2 – get a score less than 10
Effect 2 – get a cookie

Two types of conditional statements blocks are used in JavaScript:

  1. if/else statement blocks
  2. switch statement blocks

Leave a Reply