Why we have to use “break” after default


#1

Hey, please explein me is it a codecademy bug or normal condition. On first case if you not put “break”
everything works fine and I think its quite logic its not a loop so why we have to use “break” after default ?


FAQ: Conditional Statements - The switch keyword
#2

We don’t have to, and probably shouldn’t since it is moot. There are no cases below the default in a switch statement.

switch (expression) {
case expression: action; break;
case expression: action; break;
default: action;
}
// next statement after switch