𝗖𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻𝗮𝗹 𝗦𝘁𝗮𝘁𝗲𝗺𝗲𝗻𝘁𝘀 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁

Conditional statements run code based on true or false conditions. You use them to control your program flow.

Use these tools:

  • if: Runs code when a condition is true.
  • else: Runs code when the condition is false.
  • else if: Tests a new condition if the first fails.
  • switch: Handles many different options.
  • ternary (? :): A short way to write if...else.

Avoid nested if statements. They make code hard to read. Use the AND operator instead.

Ternary operators use three parts. No other JavaScript operator does this.

Source: w3schools.com Optional learning community: https://dev.to/vidhya_murali_5aabe7784bd/conditional-statements-in-javascript-49g0