---
title: "Switch Case Statement in JavaScript"  
description: "Switch Case Statement in JavaScript"  
author: "Anonymous User"  
published: 2021-07-19  
updated: 2021-07-19  
canonical: https://www.mindstick.com/forum/156517/switch-case-statement-in-javascript  
category: "javascript"  
tags: ["javascript"]  
reading_time: 2 minutes  

---

# Switch Case Statement in JavaScript

Can I use a case/[switch statement](https://www.mindstick.com/forum/55166/how-to-use-the-switch-statement-in-java) with [two variables](https://www.mindstick.com/forum/236/how-can-i-swap-two-variables-without-using-a-third-variable)?

## Replies

### Reply by Ethan Karla

Yes , you can use a two [variables](https://www.mindstick.com/articles/715/php-variables) in a [switch](https://www.mindstick.com/blog/104495/switch-bringing-new-advancements-in-the-education-management-system) case statement.

Below example can describe you how to use this condition in you javascript code.

```
<!DOCTYPE html>
<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
    <meta charset='utf-8' />
    <title>Switch Case Statement</title>
    <script>
        var color = 'blue'; var size = 'small';
            switch (true) {
                case ( color == 'blue' &&  size == 'small'):
                    document.write('blue and small');
                    break;
                case ( color == 'red' &&  size == 'large'):
                    document.write('red and large');
                    break;
                default:
                    document.write('nothing');
                    break;
            }
        ;
    </script>
</head>
<body align='center'>
</body>
</html>
```

Hope this information has cleared your confusion.

Happy Coding!


---

Original Source: https://www.mindstick.com/forum/156517/switch-case-statement-in-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
