swith multiple values js code example
Example 1: javascript switch statement multiple cases
var color = "yellow";
var darkOrLight="";
switch(color) {
case "yellow":case "pink":case "orange":
darkOrLight = "Light";
break;
case "blue":case "purple":case "brown":
darkOrLight = "Dark";
break;
default:
darkOrLight = "Unknown";
}
Example 2: multiple case switch javascript
switch (varName)
{
case "afshin":
case "saeed":
case "larry":
alert('Hey');
break;
default:
alert('Default case');
}
Example 3: javascript select multiple values
const selected = document.querySelectorAll('#select-meal-type option:checked');
const values = Array.from(selected).map(el => el.value);