Default Case
Handling no match.
Examples
Using Default
Code runs if no case matches.
let text;
switch (new Date().getDay()) {
case 6:
text = "Today is Saturday";
break;
case 0:
text = "Today is Sunday";
break;
default:
text = "Looking forward to the Weekend";
}
console.log(text);Test Your Knowledge
JavaScript Quiz
No quiz available for this topic yet.