default case switch code example
Example 1: switch js
switch(expression) {
case x:
break;
case y:
break;
default:
}
Example 2: 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);
Example 3: switch case in js
var coll1="kjc;
switch(coll1)
{
case "kjc":
alert("youre special");
break;
case "horizon":
alert("worst behaviour");
break;
case "cmr" :
alert("worst character");
break;
default:
alert("kjc is best");
break;
}