how to write a switch statement js code example
Example 1: js switch case
switch(expression) {
case x:
break;
case y:
break;
default:
}
Example 2: how to use switch case in javascript
switch (expression) {
case value1:
[break;]
case value2:
[break;]
...
case valueN:
[break;]
[default:
[break;]]
}
Example 3: javascript switch
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";
}