Adding a Default Option in Switch Statements In a switch statement you may not be able to specify all possible values as case statements. In code example
Example: adding a default option in switch statements
function switchOfStuff(val) {
var answer = "";
switch(val){
case "a":
answer = "apple";
break;
case "b":
answer = "bird";
break;
case "c":
answer = "cat";
break;
default:
answer = "stuff";
break;
}
return answer;
}
switchOfStuff(1);