javascript default switch case code example
Example 1: js switch case
switch(expression) {
case x:
break;
case y:
break;
default:
}
Example 2: Javascript switch case code format
switch(type) {
case "SomeString":
break;
case "OtherString":
break;
default:
break;
}
Example 3: switch statement javascript
function caseInSwitch(val) {
var answer = "";
switch(val) {
case 1:
answer = "alpha";
console.log(answer);
break;
case 2:
answer = "beta";
break;
case 3:
answer = "gamma";
break;
case 4:
answer = "delta";
break;
}
return answer;
}
caseInSwitch(1);