Introduction and Topic Overview

Welcome to our TypeScript undertaking. Today, we are examining the concept of conditional statements. Much like life, TypeScript's conditional statements guide the program based on various conditions.

In today's lesson, we'll cover:

  • The basic if statement — the pathway for making single-pathway decisions.
  • else and else if statements — options for making multiple decision paths.
  • Compound conditionals — workarounds for handling complex decisions involving multiple conditions.
  • The Ternary Operator — a shorthand method for making quick, straightforward decisions.
Understanding Conditional Statements - The Basic If Statement

Our exploration starts with the basic if statement, which validates a particular condition and performs an action if the condition is fulfilled. To illustrate, imagine deciding whether a watermelon is ready to eat, here's what the if statement would look like :

In the above code, the condition watermelon === 'ready' is evaluated. If it is true, the action inside the { ... } block is executed, which is in this case.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal