We can also write multiple conditions inside a single if statement with the help of the logical operators && and | | . The && operators will evaluate if one condition AND another is true. Both must be true before the code in the code block will execute.
It is used to decide whether a certain statement or block of statements will be executed or not i.e if a certain condition is true then a block of statement is executed otherwise not.
- Use Array. includes for Multiple Criteria.
- Less Nesting, Return Early. Let’s expand the previous example to include two more conditions:
- Use Default Function Parameters and Destructuring.
- Favor Map / Object Literal than Switch Statement.
- Use Array.