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

Your code needs to make decisions. Conditional statements do this. They run code blocks based on true or false results.

Use these three types:

  • if: Runs code if one condition is true.
  • if-else: Runs one block if true and another if false.
  • else if: Checks multiple conditions in order.

Learn truthy and falsy values.

Truthy values:

  • Non-zero numbers.
  • Non-empty strings.
  • Objects and arrays.

Falsy values:

  • false.
  • Empty strings.
  • null.
  • undefined.
  • NaN.

Interview tips:

  • A string with 0 is truthy.
  • Know the difference between if and if-else.
  • Memorize all falsy values.

Source: https://dev.to/ezhil_abinayak_e38eec8fb/javascript-conditional-statements-examples-flowcharts-truthy-falsy-values-and-interview-49c8