default for an on statement 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: charat javascript in swicth
function getLetter(s) {
let letter;
switch (true) {
case "aeiou".includes(s[0]):
letter = "A";
break;
case "bcdefg".includes(s[0]):
letter = "B";
break;
case "hijklm".includes(s[0]):
letter = "C";
break;
case "nopqrstuvwxyz".includes(s[0]):
letter = "D";
break;
}
return letter;
}