About 376,000 results
Open links in new tab
  1. JavaScript: using a condition in switch case - Stack Overflow

    How can I use a condition inside a switch statement for JavaScript? In the example below, a case should match when the variable liCount is <= 5 and > 0; however, my code does not work: …

  2. JavaScript Switch Statement - W3Schools

    Use the switch statement to select one of many code blocks to be executed. This is how it works: The switch expression is evaluated once. The value of the expression is compared with the …

  3. switch - JavaScript | MDN - MDN Web Docs

    Mar 13, 2025 · The switch statement evaluates an expression, matching the expression's value against a series of case clauses, and executes statements after the first case clause with a …

  4. JavaScript switch case Statement - JavaScript Tutorial

    This tutorial shows you how to use the JavaScript switch case statement to evaluate a block based on multiple conditions.

  5. JavaScript switch Statement - GeeksforGeeks

    Nov 21, 2024 · The JavaScript switch statement evaluates an expression and executes a block of code based on matching cases. It provides an alternative to long if-else chains, improving …

  6. The "switch" statement - The Modern JavaScript Tutorial

    Apr 25, 2022 · It gives a more descriptive way to compare a value with multiple variants. The switch has one or more case blocks and an optional default. It looks like this: The value of x is …

  7. JavaScript Switch Case Conditional Statements - Tutorial Republic

    In this tutorial you will learn how to use the switch...case statement to test or evaluate an expression with different values in JavaScript. The switch..case statement is an alternative to …

  8. Switch statement for multiple cases in JavaScript

    Use the fall-through feature of the switch statement. A matched case will run until a break (or the end of the switch statement) is found, so you could write it like: case "afshin": case "saeed": …

  9. How To Use the Switch Statement in JavaScript - DigitalOcean

    Aug 26, 2021 · In addition to if...else, JavaScript has a feature known as a switch statement. switch is a type of conditional statement that will evaluate an expression against multiple …

  10. JavaScript Switch Case: A Step-by-Step Guide with Examples

    Jan 8, 2025 · The JavaScript switch case statement is a powerful tool used to execute different blocks of code based on different conditions. It’s a great way to simplify complex conditional …