2018-10-12 15:37:13 -04:00
---
title: Multiple Identical Options in Switch Statements
---
2019-07-24 00:59:27 -07:00
# Multiple Identical Options in Switch Statements
2018-10-12 15:37:13 -04:00
2019-07-24 00:59:27 -07:00
## Code Solutions
2018-10-12 15:37:13 -04:00
2019-07-24 00:59:27 -07:00
< details > < summary > Solution 1 (Click to Show/Hide)< / summary >
2018-10-12 15:37:13 -04:00
```javascript
function sequentialSizes(val) {
var answer = "";
// Only change code below this line
2019-03-29 09:36:58 -07:00
switch (val) {
2018-10-12 15:37:13 -04:00
case 1:
case 2:
case 3:
return "Low";
break;
case 4:
case 5:
case 6:
return "Mid";
break;
case 7:
case 8:
case 9:
return "High";
break;
2019-07-24 00:59:27 -07:00
}
// Only change code above this line
return answer;
2018-10-12 15:37:13 -04:00
}
// Change this value to test
sequentialSizes(1);
```
2019-07-24 00:59:27 -07:00
< / details >
< details > < summary > Solution 1 (Click to Show/Hide)< / summary >
2018-10-12 15:37:13 -04:00
```javascript
function sequentialSizes(val) {
var answer = "";
// Only change code below this line
2019-07-24 00:59:27 -07:00
switch (val) {
case 1:
case 2:
case 3:
2018-10-12 15:37:13 -04:00
answer = "Low";
break;
2019-07-24 00:59:27 -07:00
case 4:
case 5:
case 6:
2018-10-12 15:37:13 -04:00
answer = "Mid";
break;
2019-07-24 00:59:27 -07:00
case 7:
case 8:
case 9:
2018-10-12 15:37:13 -04:00
answer = "High";
}
2019-07-24 00:59:27 -07:00
// Only change code above this line
return answer;
2018-10-12 15:37:13 -04:00
}
// Change this value to test
sequentialSizes(1);
```
2019-07-24 00:59:27 -07:00
#### Code Explanation
2018-10-12 15:37:13 -04:00
Since you already have a variable named `answer` defined and the function returns it, you can just modify its value on each group of case statements to fit the exercise requirements.
2019-07-24 00:59:27 -07:00
#### Relevant Links
2019-03-28 09:35:41 +01:00
- ["Switch: Methods for multi-criteria case" - *MDN JavaScript Reference* ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch )
2019-07-24 00:59:27 -07:00
< / details >