---
title: "Switch statement for multiple cases in JavaScript"  
description: "Switch statement for multiple cases in JavaScript"  
author: "Ashutosh Patel"  
published: 2025-03-24  
updated: 2025-03-25  
canonical: https://www.mindstick.com/forum/161341/switch-statement-for-multiple-cases-in-javascript  
category: "javascript"  
tags: ["javascript", "javascript object"]  
reading_time: 2 minutes  

---

# Switch statement for multiple cases in JavaScript

[Switch statement](https://www.mindstick.com/forum/55166/how-to-use-the-switch-statement-in-java) for [multiple](https://www.mindstick.com/blog/12797/iowa-is-expected-to-see-heavy-growth-in-multiple-sectors) cases in JavaScript

## Replies

### Reply by Khushi Singh

The **[switch](https://www.mindstick.com/blog/104495/switch-bringing-new-advancements-in-the-education-management-system) statement in** [**JavaScript**](https://www.mindstick.com/articles/1036/javascript) performs expression evaluation and runs block code depending on matching case conditions. A series of cases with identical results can share combined code blocks instead of using duplicate code. As a switch exits with a break after running any chosen case, it automatically prevents additional case evaluations. When an expression matches no cases, the default case will execute.

## Example: Handling Multiple Cases in a Switch Statement

```javascript
let day = "Saturday";
switch (day) {
   case "Monday":
   case "Tuesday":
   case "Wednesday":
   case "Thursday":
   case "Friday":
       console.log("It's a weekday.");
       break;
   case "Saturday":
   case "Sunday":
       console.log("It's the weekend!");
       break;
   default:
       console.log("Invalid day.");
}
```

## Explanation:

- The switch declaration examines the day variable value for assessment.
- All weekdays starting from "Monday" through "Friday" follow consistent logic, thus receiving their group execution before triggering the code block of “It's a weekday.”
- The statements "It's the weekend!" function once through the grouping of "Saturday" and "Sunday".
- The default "Invalid day" message will execute when the day fails to match any previous cases.

By grouping multiple values in cases, the program becomes more readable and reduces duplicate code for similar scenarios.

**Learn tips and tricks for learning JavaScript faster,** [in this article](https://www.mindstick.com/articles/279873/learn-javascript-faster-tips-and-advice-for-beginners)


---

Original Source: https://www.mindstick.com/forum/161341/switch-statement-for-multiple-cases-in-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
